home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34src.zip
/
me3
/
mutt
/
builtin
/
bstats.mut
< prev
next >
Wrap
Lisp/Scheme
|
1995-01-14
|
4KB
|
156 lines
;; bstats.mut : buffer stats
;; C Durland Public Domain
;; Last modified: 11/92
(include me.mh)
(include tobase.mut)
(defun
show-buffer-stats
{
(int buffer-size dot lines buffer-row wasted char-at-dot) ;; BufferInfo
(int ratio)
(buffer-stats -1 (loc buffer-size))
(ratio 0)(if (!= 0 buffer-size)(ratio (/ (* 100 dot) buffer-size)))
(msg "Row: " buffer-row "/" lines " Column: " (current-column)
" CH: 0x" (tobase char-at-dot 16)
" (" ratio "% of " buffer-size ")")
}
)
;; Display a buffer in another window, creating a window if need be.
;; If the buffer is already in a window, nothing is done.
;; Input:
;; buffer-id : id of the buffer to be displayed
;; Optional:
;; row : row to put the dot on.
;; column : column to put the dot at.
;; If row and column not passed in, dot is not moved.
;; Output:
;; Id of the window that is showing the buffer.
(defun
popup-buffer (int buffer-id) (int row column)
{
(int j)
(j 0)(while (< j (windows))
{
(if (== buffer-id (attached-buffer j)) ;; window j is showing buffer
{ (place-dot j (push-args 1)) j (done) })
(+= j 1)
})
(if (== (windows) 1)(split-window))
(next-window)
(current-buffer buffer-id TRUE)
(place-dot (j (current-window)) (push-args 1))
(previous-window)
j
}
place-dot (int w)(int row column) HIDDEN
{
(int cw)
(if (== 1 (nargs)) (done))
(cw (current-window))
(current-window w)
(current-line row)(current-column column)
(update FALSE) ;; force the dot
(current-window cw)
}
)
;; Put a list of buffer into a buffer. Show various infos about those
;; buffers.
;; Format:
;; Flags buffer-size buffer-name file-name
;; Modified
;; Undo turned on
;; hidden - hard
;; hidden - soft
;; MUhH, dashes used if flag not set.
;; Notes:
;; This does a few (minor) things for the benefit of of buffer-menu.
(const
END-SIZE-COL 13
BUF-COL 14
FILE-COL 28 ;; The real file column - 1
)
(defun
list-buffers
{
(int buffer-size dot lines row wasted char-at-dot) ;; struct BufferInfo
(int total-bytes total-lines)
(int j num-buffers cw bp bp1 wp old-curbp)
(if (arg-flag)
{
(arg-flag FALSE 1) ;; reset arg count
(if (pgm-exists "buffer-menu")
{
(floc "buffer-menu"()) ;; recursive - calls list-buffers
(done)
})
})
(num-buffers (total-bytes (total-lines 0)))
(old-curbp (current-buffer))
(if (== -2 (bp (attached-buffer "*buffer-list*")))
(bp (create-buffer "*buffer-list*" BFHooHum)))
(current-buffer bp)(buffer-read-only FALSE)
(clear-buffer)
(insert-text "Flags Size Buffer File")(newline)
(insert-text "----- ---- ------ ----")(newline)
(for (j 0) (< j (buffers)) (+= j 1)
{
(bp1 (nth-buffer j))
(if (!= bp bp1)
{
(buffer-stats bp1 (loc buffer-size))
(insert-text " ") ;; for buffer menu
(if (!= 0 (bit-and BFNoCare (buffer-flags bp1)))
(insert-text ".")
(show-flag bp1 BFModified "M"))
(show-flag bp1 BFUndo "u")
(show-flag bp1 BFHidden "H")
(show-flag bp1 BFHidden2 "h")
(to-col (- END-SIZE-COL (length-of (concat buffer-size))))
(insert-text buffer-size)
(insert-text " " (buffer-name bp1))
;; " " in case the buffer name is long
(to-col FILE-COL) (insert-text " " (file-name bp1))
(newline)
(+= num-buffers 1)(+= total-bytes buffer-size)(+= total-lines lines)
})
})
(newline)
(to-col (- 9 (length-of (concat total-bytes))))
(insert-text total-bytes " bytes (" total-lines " lines) in "
num-buffers " buffers. ")
(buffer-modified -1 FALSE)
(buffer-read-only TRUE) ;; mostly for buffer-menu
(current-buffer old-curbp)
(popup-buffer bp 3 BUF-COL) ;; and return the window id
}
show-flag (int buffer-id flag)(string flag-on) HIDDEN
{
(insert-text
(if (!= 0 (bit-and flag (buffer-flags buffer-id))) flag-on "-"))
}
)