mirror of https://codeberg.org/cage/tinmop/
- fixed search in message-window;
- there was a lot of problems related to type of an element of 'rows', they must be always a complex string - moreover there was an incorrect positioning of the matching string when character with column width >1 was present before the string compatible with the regex.
This commit is contained in:
parent
9572f2a917
commit
816a04812d
|
@ -140,11 +140,11 @@
|
||||||
|
|
||||||
(defmethod text->rendered-lines-rows (window (text gemini-parser:pre-start))
|
(defmethod text->rendered-lines-rows (window (text gemini-parser:pre-start))
|
||||||
(make-instance 'line
|
(make-instance 'line
|
||||||
:normal-text ""))
|
:normal-text (make-tui-string "")))
|
||||||
|
|
||||||
(defmethod text->rendered-lines-rows (window (text gemini-parser:pre-end))
|
(defmethod text->rendered-lines-rows (window (text gemini-parser:pre-end))
|
||||||
(make-instance 'line
|
(make-instance 'line
|
||||||
:normal-text ""))
|
:normal-text (make-tui-string "")))
|
||||||
|
|
||||||
(defmethod text->rendered-lines-rows (window (text list))
|
(defmethod text->rendered-lines-rows (window (text list))
|
||||||
(flatten (loop for i in text
|
(flatten (loop for i in text
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
(reverse res))))
|
(reverse res))))
|
||||||
(if (string= text (format nil "~%"))
|
(if (string= text (format nil "~%"))
|
||||||
(make-instance 'line
|
(make-instance 'line
|
||||||
:normal-text nil)
|
:normal-text (make-tui-string ""))
|
||||||
(let* ((lines (split-lines text))
|
(let* ((lines (split-lines text))
|
||||||
(fitted-lines (fit-lines lines))
|
(fitted-lines (fit-lines lines))
|
||||||
(new-rows (colorize-lines fitted-lines)))
|
(new-rows (colorize-lines fitted-lines)))
|
||||||
|
@ -279,7 +279,9 @@
|
||||||
(defun first-line->string (window)
|
(defun first-line->string (window)
|
||||||
(with-accessors ((rows rows)
|
(with-accessors ((rows rows)
|
||||||
(row-selected-index row-selected-index)) window
|
(row-selected-index row-selected-index)) window
|
||||||
(tui-string->chars-string (normal-text (elt rows row-selected-index)))))
|
(let ((complex (normal-text (elt rows row-selected-index))))
|
||||||
|
(values (tui-string->chars-string complex)
|
||||||
|
complex))))
|
||||||
|
|
||||||
(defmethod search-regex ((object message-window) regex)
|
(defmethod search-regex ((object message-window) regex)
|
||||||
(with-accessors ((rows rows)
|
(with-accessors ((rows rows)
|
||||||
|
@ -293,15 +295,21 @@
|
||||||
(when line-found
|
(when line-found
|
||||||
(row-move object (- line-found row-selected-index))
|
(row-move object (- line-found row-selected-index))
|
||||||
(draw object)
|
(draw object)
|
||||||
(let ((line (first-line->string object)))
|
(multiple-value-bind (first-window-line-simple first-window-line-complex)
|
||||||
|
(first-line->string object)
|
||||||
(labels ((highlight (&optional (start-scan 0))
|
(labels ((highlight (&optional (start-scan 0))
|
||||||
(multiple-value-bind (start end)
|
(multiple-value-bind (start end)
|
||||||
(scan regex line :start start-scan)
|
(scan regex first-window-line-simple :start start-scan)
|
||||||
(when start
|
(when start
|
||||||
(let ((mask (make-tui-string (subseq line start end)
|
(let* ((mask (make-tui-string (subseq first-window-line-simple
|
||||||
:fgcolor (win-bgcolor object)
|
start end)
|
||||||
:bgcolor (win-fgcolor object))))
|
:fgcolor (win-bgcolor object)
|
||||||
(print-text object mask (1+ start) 1)
|
:bgcolor (win-fgcolor object)))
|
||||||
|
(prefix (tui-string-subseq first-window-line-complex
|
||||||
|
0
|
||||||
|
start))
|
||||||
|
(new-prefix (cat-tui-string prefix mask)))
|
||||||
|
(print-text object new-prefix 1 1)
|
||||||
(highlight end))))))
|
(highlight end))))))
|
||||||
(highlight)))))))
|
(highlight)))))))
|
||||||
|
|
||||||
|
|
|
@ -1186,6 +1186,7 @@
|
||||||
:cat-tui-string
|
:cat-tui-string
|
||||||
:tui-char->char
|
:tui-char->char
|
||||||
:tui-string->chars-string
|
:tui-string->chars-string
|
||||||
|
:tui-string-subseq
|
||||||
:text-ellipsis
|
:text-ellipsis
|
||||||
:right-pad-text
|
:right-pad-text
|
||||||
:text->tui-attribute
|
:text->tui-attribute
|
||||||
|
|
|
@ -437,7 +437,7 @@
|
||||||
(handler-case
|
(handler-case
|
||||||
(let ((scanner (cl-ppcre:create-scanner regexp :case-insensitive-mode t)))
|
(let ((scanner (cl-ppcre:create-scanner regexp :case-insensitive-mode t)))
|
||||||
(message-window:search-regex specials:*message-window* scanner))
|
(message-window:search-regex specials:*message-window* scanner))
|
||||||
(error ()
|
(cl-ppcre:ppcre-syntax-error ()
|
||||||
(ui:error-message (_ "Invalid regular expression")))))))
|
(ui:error-message (_ "Invalid regular expression")))))))
|
||||||
|
|
||||||
(defclass thread-search-event (search-event)
|
(defclass thread-search-event (search-event)
|
||||||
|
|
|
@ -184,6 +184,9 @@ as argument `complex-string'."
|
||||||
"Convert a `tui-string' to a `string'."
|
"Convert a `tui-string' to a `string'."
|
||||||
(croatoan:complex-string->chars-string tui-string))
|
(croatoan:complex-string->chars-string tui-string))
|
||||||
|
|
||||||
|
(defun tui-string-subseq (string start end)
|
||||||
|
(croatoan:text-slice string start end))
|
||||||
|
|
||||||
(defgeneric text-ellipsis (object len &key truncate-string)
|
(defgeneric text-ellipsis (object len &key truncate-string)
|
||||||
(:documentation "If `object''s length is bigger than `len', cut the last characters
|
(:documentation "If `object''s length is bigger than `len', cut the last characters
|
||||||
out. Also replaces the last n characters (where n is the length of
|
out. Also replaces the last n characters (where n is the length of
|
||||||
|
|
Loading…
Reference in New Issue