mirror of
https://codeberg.org/cage/tinmop/
synced 2025-01-31 04:24:48 +01:00
- optimized module 'rewrite-message-urls.lisp'.
This commit is contained in:
parent
0cd1f77c7f
commit
02894dcc64
@ -65,25 +65,30 @@ So the whole list is like: '((\"foo\" \"bar\") (\"old\" \"new\") ...)")
|
||||
(or (message-window:row-invisible-p row)
|
||||
(find-if (lambda (a) (typep original-type a)) skipped-row-types))))
|
||||
|
||||
(defun %rewriting-link-rewrite-row (links-mapping)
|
||||
(lambda (row)
|
||||
(let* ((original-string (line-oriented-window:normal-text row)))
|
||||
(if (skipped-row-p row)
|
||||
row
|
||||
(let* ((simple-string (tui:tui-string->chars-string original-string))
|
||||
(defun rewriting-link-rewrite-row (window index links-mapping)
|
||||
(with-accessors ((rows line-oriented-window:rows)) window
|
||||
(when rows
|
||||
(let* ((row (elt rows index))
|
||||
(original-string (line-oriented-window:normal-text row)))
|
||||
(when (not (skipped-row-p row))
|
||||
(let* ((simple-string (tui:tui-string->chars-string original-string))
|
||||
(replaced-string simple-string))
|
||||
(loop for mapping in links-mapping do
|
||||
(setf replaced-string
|
||||
(rewriting-link-replace-mapping mapping replaced-string)))
|
||||
replaced-string)))))
|
||||
(setf (line-oriented-window:normal-text row)
|
||||
(message-window::colorize-lines replaced-string))
|
||||
(setf (elt rows index)
|
||||
(message-window:text->rendered-lines-rows window row))))))))
|
||||
|
||||
(defun rewriting-link-message-hook-fn (message-window)
|
||||
(let* ((map-fn (%rewriting-link-rewrite-row *rewriting-link-rules*))
|
||||
(replaced-rows (line-oriented-window:rows-map-raw message-window
|
||||
map-fn))
|
||||
(new-rows (message-window:text->rendered-lines-rows message-window
|
||||
replaced-rows)))
|
||||
(line-oriented-window:update-all-rows message-window new-rows)))
|
||||
(multiple-value-bind (x start-visible-index end-visible-index)
|
||||
(message-window:visible-rows message-window)
|
||||
(declare (ignore x))
|
||||
(loop for i from start-visible-index below end-visible-index do
|
||||
(rewriting-link-rewrite-row message-window i *rewriting-link-rules*))
|
||||
message-window))
|
||||
|
||||
|
||||
(defun rewriting-link-links-window-hook-fn (all-links)
|
||||
(let ((links-mapping (rewriting-link-messages-links-rules all-links))
|
||||
|
@ -100,13 +100,24 @@
|
||||
(defmethod calculate ((object message-window) dt)
|
||||
(declare (ignore object dt)))
|
||||
|
||||
(defun visible-rows (window)
|
||||
(with-accessors ((row-selected-index row-selected-index)) window
|
||||
(let* ((start row-selected-index)
|
||||
(end (+ start
|
||||
(win-height-no-border window))))
|
||||
(values (line-oriented-window:rows-safe-subseq window
|
||||
row-selected-index
|
||||
:end end)
|
||||
start
|
||||
end))))
|
||||
|
||||
(defun draw-text (window)
|
||||
(when hooks:*before-rendering-message-text*
|
||||
(hooks:run-hook 'hooks:*before-rendering-message-text* window))
|
||||
(with-accessors ((row-selected-index row-selected-index)) window
|
||||
(let ((actual-rows (line-oriented-window:rows-safe-subseq window row-selected-index)))
|
||||
(loop for line in actual-rows
|
||||
for y from 1 below (win-height-no-border window)
|
||||
(let ((visible-rows (visible-rows window)))
|
||||
(loop for line in visible-rows
|
||||
for y from 1
|
||||
do
|
||||
(cond
|
||||
;; testing invisibility should never returns true as
|
||||
|
@ -1941,6 +1941,7 @@
|
||||
:display-chat-p
|
||||
:row-get-original-object
|
||||
:viewport-width
|
||||
:visible-rows
|
||||
:row-vertical-space-p
|
||||
:row-preformatted-p
|
||||
:row-invisible-p
|
||||
|
Loading…
x
Reference in New Issue
Block a user