(defun lurk-set-current-context (context)
(setq lurk-current-context context)
(lurk-highlight-context context)
+ (lurk-render-prompt)
(if lurk-zoomed
(lurk-zoom-in lurk-current-context)))
(defun lurk-cycle-contexts (&optional rev)
(if lurk-current-context
- (progn
- (lurk-set-current-context (lurk-get-next-context rev))
- (lurk-render-prompt))
+ (lurk-set-current-context (lurk-get-next-context rev))
(lurk-display-error "No channels joined.")))
(if lurk-display-header
(lurk-setup-header))))
+(defun lurk-clear-buffer ()
+ "Completely erase all non-prompt and non-input text from lurk buffer."
+ (with-current-buffer "*lurk*"
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) lurk-prompt-marker))))
;;; Output formatting and highlighting
;;
(with-selected-window window
(recenter -1))))))
+(defun lurk-make-context-button (context &optional label)
+ (with-temp-buffer
+ (insert-text-button (or label context)
+ 'action #'lurk--context-button-action
+ 'follow-link t
+ 'help-echo "Switch context.")
+ (buffer-string)))
+
+(defun lurk--context-button-action (button)
+ (let ((context (button-get button 'context)))
+ (if (eq lurk-current-context context)
+ (lurk-toggle-zoom)
+ (lurk-set-current-context context))))
+
(defun lurk-display-string (context prefix &rest strings)
(with-current-buffer "*lurk*"
(save-excursion
context
(propertize
(pcase (lurk-get-context-type to)
- ('channel (concat to " <" from ">"))
- ('nick (concat "[" from " -> " to "]"))
+ ('channel (concat
+ (lurk-make-context-button to)
+ " <" from ">"))
+ ('nick (lurk-make-context-button context (concat "[" from " -> " to "]")))
(_
(error "Unsupported context type")))
'face (lurk-get-context-facelist context))
(lurk-display-string
context
(propertize
- (concat context " * " from)
+ (concat (lurk-make-context-button context) " * " from)
'face (lurk-get-context-facelist context))
action-text)))
(force-window-update "*lurk*"))
(lurk-scroll-windows-to-last-line))
+(defun lurk-clear-context (context)
+ (with-current-buffer "*lurk*"
+ (save-excursion
+ (goto-char (point-min))
+ (let ((inhibit-read-only t)
+ (match nil))
+ (while (setq match (text-property-search-forward 'context context t))
+ (delete-region (prop-match-beginning match)
+ (prop-match-end match)))))))
+
(defconst lurk-url-regex
(rx (:
(group (+ alpha))
(strikethrough nil)
(prev-point (point)))
(while (re-search-forward (rx (or (any "\x02\x1D\x1F\x1E\x0F")
- (: "\x03" (+ digit) (opt "," (* digit))))) nil t)
+ (: "\x03" (+ digit) (opt "," (* digit)))))
+ nil t)
(let ((beg (+ (match-beginning 0) 1)))
(if bold
(add-face-text-property prev-point beg '(:weight bold)))
("LIST" "Display details of one or more channels." lurk-command-list)
("WHOIS" "Ask server for details of nick." nil lurk-nick-completions)
("MSG" "Send private message to user." lurk-command-msg lurk-nick-completions)
+ ("CLEAR" "Clear buffer text." lurk-command-clear lurk-context-completions)
("HELP" "Display help on client commands." lurk-command-help lurk-help-completions))
"Table of commands explicitly supported by Lurk.")
(lurk-display-message lurk-nick to text))
(lurk-display-notice nil "Usage: /msg <nick> <message>")))
+(defun lurk-command-clear (params)
+ (if (not params)
+ (lurk-clear-buffer)
+ (dolist (context params)
+ (lurk-clear-context context))))
;;; Command entering
;;