scroll.c 444 B

1234567891011121314151617181920212223242526272829
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <draw.h>
  4. int
  5. mousescrollsize(int maxlines)
  6. {
  7. static int lines, pcnt;
  8. char *mss;
  9. if(lines == 0 && pcnt == 0){
  10. mss = getenv("mousescrollsize");
  11. if(mss){
  12. if(strchr(mss, '%') != nil)
  13. pcnt = atof(mss);
  14. else
  15. lines = atoi(mss);
  16. free(mss);
  17. }
  18. if(lines == 0 && pcnt == 0)
  19. lines = 1;
  20. if(pcnt>=100)
  21. pcnt = 100;
  22. }
  23. if(lines)
  24. return lines;
  25. return pcnt * maxlines/100.0;
  26. }