* riece-ctlseq.el (riece-ctlseq-scan-region): Abolish.
[riece] / lisp / riece-highlight.el
index addb260..b7f3a38 100644 (file)
 (defface riece-channel-list-current-face
   '((((class color)
       (background dark))
-     (:foreground "PaleTurquoise" :underline t))
+     (:foreground "turquoise" :underline t))
     (((class color)
       (background light))
-     (:foreground "ForestGreen" :underline t))
+     (:foreground "SeaGreen" :underline t))
     (t
      ()))
   "Face used for displaying the current channel."
     (if (looking-at riece-prefix-regexp)
        (put-text-property (match-beginning 1) (match-end 1) 'invisible t))))
 
-(defun riece-channel-list-mark-current-channel (last)
-  (if (and riece-channel-list-buffer-mode
-          riece-current-channel)
-      (save-excursion
-       (set-buffer riece-channel-list-buffer)
-       (let ((inhibit-read-only t)
-             buffer-read-only)
-         (goto-char (point-min))
-         (if (re-search-forward "^\\( ?[0-9]+:\\)\\*" nil t)
-             (replace-match "\\1 "))
-         (goto-char (point-min))
-         (if (re-search-forward
-              (concat
-               "^\\( ?[0-9]+:\\).\\("
-               (regexp-quote (riece-format-identity riece-current-channel))
-               "\\)$") nil t)
-             (replace-match "\\1*\\2"))))))
+(defun riece-put-overlay-faces (start end)
+  (riece-scan-property-region
+   'riece-overlay-face
+   start end
+   (lambda (start end)
+     (riece-overlay-put (riece-make-overlay start end)
+                       'face
+                       (get-text-property start 'riece-overlay-face)))))
 
 (defun riece-channel-list-turn-on-font-lock ()
   (make-local-variable 'font-lock-defaults)
   (setq font-lock-mode-hook nil)
   (turn-on-font-lock))
 
+(defun riece-highlight-format-identity-for-channel-list-indicator (index
+                                                                  identity)
+  (if (riece-identity-equal identity riece-current-channel)
+      (let ((string (riece-format-identity identity))
+           (start 0))
+       ;; Escape % -> %%.
+       (while (string-match "%" string start)
+         (setq start (1+ (match-end 0))
+               string (replace-match "%%" nil nil string)))
+       (list (format "%d:" index)
+             (riece-propertize-modeline-string
+              string 'face 'riece-channel-list-current-face)))))
+
 (defun riece-highlight-insinuate ()
   (put 'riece-channel-mode 'font-lock-defaults
        '(riece-dialogue-font-lock-keywords t))
            'riece-dialogue-schedule-turn-on-font-lock)
   (put 'riece-channel-list-mode 'font-lock-defaults
        '(riece-channel-list-font-lock-keywords t))
-  (add-hook 'riece-after-switch-to-channel-functions
-           'riece-channel-list-mark-current-channel)
   (add-hook 'riece-after-load-startup-hook
-           'riece-channel-list-schedule-turn-on-font-lock))
+           'riece-channel-list-schedule-turn-on-font-lock)
+  (add-hook 'riece-format-identity-for-channel-list-indicator-functions
+           'riece-highlight-format-identity-for-channel-list-indicator)
+  (add-hook 'riece-after-insert-functions 'riece-put-overlay-faces))
 
 (provide 'riece-highlight)