Function: newsticker--display-scroll
newsticker--display-scroll is a byte-compiled function defined in
newst-ticker.el.gz.
Signature
(newsticker--display-scroll)
Documentation
Called from the display timer.
This function scrolls the ticker items in the echo area, unless there is another message displayed or the minibuffer is active.
Source Code
;; Defined in /usr/src/emacs/lisp/net/newst-ticker.el.gz
(defun newsticker--display-scroll ()
"Called from the display timer.
This function scrolls the ticker items in the echo area, unless
there is another message displayed or the minibuffer is active."
(when (newsticker--echo-area-clean-p)
(let* ((width (- (frame-width) 1))
(message-log-max nil);; prevents message text from being logged
(i newsticker--item-position)
subtext
(s-text newsticker--scrollable-text)
(l (length s-text)))
;; don't show anything if there is nothing to show
(unless (< (length s-text) 1)
;; repeat the ticker string if it is shorter than frame width
(while (< (length s-text) width)
(setq s-text (concat s-text s-text)))
;; get the width of the printed string
(setq l (length s-text))
(cond ((< i (- l width))
(setq subtext (substring s-text i (+ i width))))
(t
(setq subtext (concat
(substring s-text i l)
(substring s-text 0 (- width (- l i)))))))
;; Take care of multibyte strings, for which (string-width) is
;; larger than (length).
;; Actually, such strings may be smaller than (frame-width)
;; because return values of (string-width) are too large:
;; (string-width "<japanese character>") => 2
(let ((t-width (1- (length subtext))))
(while (> (string-width subtext) width)
(setq subtext (substring subtext 0 t-width))
(setq t-width (1- t-width))))
;; show the ticker text and save current position
(message "%s" subtext)
(setq newsticker--prev-message subtext)
(setq newsticker--item-position (1+ i))
(when (>= newsticker--item-position l)
(setq newsticker--item-position 0)
(when (> newsticker-ticker-period 0)
(cancel-timer newsticker--ticker-timer)
(setq newsticker--ticker-timer nil)
(run-at-time newsticker-ticker-interval nil
(lambda () (message "")))))))))