home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mutt / bstats.mut < prev    next >
Text File  |  1988-09-14  |  2KB  |  64 lines

  1.     ; bstats.mut : buffer stats
  2.     ; C Durland
  3.  
  4. (include me.h)
  5. (include tobase.mut)
  6.  
  7. (defun
  8.   show-buffer-stats
  9.   {
  10.     (INT buffer-size dot lines buffer-row wasted char-at-dot ratio)
  11.   
  12.     (buffer-stats -1 (loc buffer-size))
  13.     (ratio 0)(if (!= 0 buffer-size)(ratio (/ (* 100 dot) buffer-size)))
  14.     (msg "Row: " buffer-row "/" lines  " Column: " (current-column)
  15.     " CH: 0x" (tobase char-at-dot 16) 
  16.     " (" ratio "% of " buffer-size ") Unused: " wasted)
  17.   }
  18. )
  19.  
  20. (defun
  21.   popup-buffer(string name)(int flags) HIDDEN    ; return window buffer is in
  22.   {
  23.     (int j)
  24.     (j 0)(while (< j (windows))
  25.     {
  26.       (if (== name (buffer-name (attached-buffer j))) { j (done) })
  27.       (+= j 1)
  28.     })
  29.     (if (== (windows) 1)(split-window))
  30.     (next-window)(switch-to-buffer name)(buffer-flags -1 flags)
  31.     (j (current-window))(previous-window)
  32.     j
  33.   }
  34.   switch-to-window(int n) HIDDEN
  35.     { (arg-prefix (- n (current-window)))(next-window) }
  36.   list-buffers
  37.   {
  38.     (INT buffer-size dot lines row wasted char-at-dot ratio total)
  39.     (int j n cw bp wp)
  40.   
  41.     (n (total 0))
  42.     (wp (popup-buffer "*buffer-list*" BFGone))
  43.     (cw (current-window))(switch-to-window wp)(bp (current-buffer))
  44.     (clear-buffer -1 "yes")
  45.     (insert-text "C   Size Buffer           File")(newline)
  46.     (insert-text "-   ---- ------           ----")(newline)
  47.     (for (j 0) (< j (buffers)) (+= j 1)
  48.     {
  49.       (if (!= bp j)
  50.       {
  51.     (buffer-stats j (loc buffer-size))
  52.     (insert-text (if (buffer-modified j)("*")(" ")))
  53.     (to-col (- 9 (strlen (concat buffer-size))))(insert-text buffer-size)
  54.     (insert-text " " (buffer-name j))
  55.     (to-col 27)(insert-text (file-name j))
  56.     (newline)
  57. (+= n 1)(+= total buffer-size)
  58.       })
  59.     })
  60. (newline)(insert-text "  " total " bytes in " n " files")
  61.     (beginning-of-buffer)(buffer-modified -1 FALSE)(switch-to-window cw)
  62.   }
  63. )
  64.