* riece-layout.el: No longer provided as an add-on.
[riece] / lisp / riece-display.el
index 31a3bf6..9a2400e 100644 (file)
 (require 'riece-options)
 (require 'riece-channel)
 (require 'riece-misc)
-
-(defcustom riece-configure-windows-function #'riece-configure-windows
-  "Function to configure windows."
-  :type 'function
-  :group 'riece-looks)
-
-(defcustom riece-configure-windows-predicate
-  #'riece-configure-windows-predicate
-  "Function to check whether window reconfiguration is needed."
-  :type 'function
-  :group 'riece-looks)
+(require 'riece-layout)
 
 (defvar riece-update-buffer-functions
   '(riece-update-user-list-buffer
   "Non-nil means the buffer needs to be updated.
 Local to the buffers.")
 
-(defun riece-configure-windows ()
-  (let ((buffer (window-buffer))
-       (show-user-list
-        (and riece-user-list-buffer-mode
-             riece-current-channel
-             ;; User list buffer is nuisance for private conversation.
-             (riece-channel-p (riece-identity-prefix
-                               riece-current-channel)))))
-    ;; Can't expand minibuffer to full frame.
-    (if (eq (selected-window) (minibuffer-window))
-       (other-window 1))
-    (delete-other-windows)
-    (if (and riece-current-channel
-            (or show-user-list riece-channel-list-buffer-mode))
-       (let ((rest-window (split-window (selected-window)
-                                        (/ (window-width) 5) t)))
-         (if (and show-user-list riece-channel-list-buffer-mode)
-             (progn
-               (set-window-buffer (split-window)
-                                  riece-channel-list-buffer)
-               (set-window-buffer (selected-window)
-                                  riece-user-list-buffer))
-           (if show-user-list
-               (set-window-buffer (selected-window)
-                                  riece-user-list-buffer)
-             (if riece-channel-list-buffer-mode
-                 (set-window-buffer (selected-window)
-                                    riece-channel-list-buffer))))
-         (select-window rest-window)))
-    (if (and riece-current-channel
-            riece-channel-buffer-mode)
-       (let ((rest-window (split-window)))
-         (set-window-buffer (selected-window)
-                            riece-channel-buffer)
-         (set-window-buffer (split-window rest-window 4)
-                            riece-others-buffer)
-         (with-current-buffer riece-channel-buffer
-           (setq truncate-partial-width-windows nil))
-         (with-current-buffer riece-others-buffer
-           (setq truncate-partial-width-windows nil))
-         (set-window-buffer rest-window
-                            riece-command-buffer))
-      (set-window-buffer (split-window (selected-window) 4)
-                        riece-dialogue-buffer)
-      (set-window-buffer (selected-window)
-                        riece-command-buffer))
-    (riece-set-window-points)
-    (select-window (or (get-buffer-window buffer)
-                      (get-buffer-window riece-command-buffer)))))
-
-(defun riece-configure-windows-top (&optional plist)
-  "Candidate of `riece-configure-windows-function'.
-PLIST accept :command-height, :user-list-width, and :channel-list-width."
-  (let ((command-height (or (plist-get plist :command-height) 4))
-       (user-list-width (or (plist-get plist :user-list-width) (+ 9 1 1)))
-       (channel-list-width (or (plist-get plist :channel-list-width) 18))
-       (buffer (window-buffer))
-       (show-user-list
-        (and riece-user-list-buffer-mode
-             riece-current-channel
-             ;; User list buffer is nuisance for private conversation.
-             (riece-channel-p (riece-identity-prefix
-                               riece-current-channel)))))
-    ;; Can't expand minibuffer to full frame.
-    (when (eq (selected-window) (minibuffer-window))
-      (other-window 1))
-    (delete-other-windows)
-    ;; top of frame
-    (let ((rest-window (split-window (selected-window) command-height)))
-      (set-window-buffer (selected-window)
-                        riece-command-buffer)
-      (select-window rest-window))
-    ;; middle of frame (vertical-spilit when need)
-    (when (or (and riece-current-channel riece-channel-buffer-mode)
-             show-user-list)
-      (let ((rest-window
-            (split-window (selected-window)
-                          (/ (* 5 (+ (window-height) command-height)) 8))))
-       (cond
-        ;; channel-buffer + user-list
-        ((and show-user-list
-              (and riece-current-channel riece-channel-buffer-mode))
-         (let ((user-list-window (split-window (selected-window) nil t)))
-           (set-window-buffer (selected-window) riece-channel-buffer)
-           (set-window-buffer user-list-window riece-user-list-buffer)
-           (select-window user-list-window)
-           (shrink-window-horizontally (- (window-width) user-list-width))))
-        ;; only user-list
-        (show-user-list
-         (set-window-buffer (selected-window) riece-user-list-buffer))
-        ;; only channel-buffer
-        (riece-channel-buffer-mode
-         (set-window-buffer (selected-window) riece-channel-buffer)))
-       (select-window rest-window)))
-    ;; bottom of frame
-    (if (and riece-current-channel
-            riece-channel-list-buffer-mode)
-       (let ((channel-list-window (split-window (selected-window) nil t)))
-         (set-window-buffer (selected-window) riece-others-buffer)
-         (set-window-buffer channel-list-window riece-channel-list-buffer)
-           (select-window channel-list-window)
-           (shrink-window-horizontally (- (window-width) channel-list-width)))
-      (set-window-buffer (selected-window) riece-dialogue-buffer))
-    (riece-set-window-points)
-    (select-window (or (get-buffer-window buffer)
-                      (get-buffer-window riece-command-buffer)))))
-
-(defun riece-set-window-points ()
-  (if (get-buffer-window riece-user-list-buffer)
-      (with-current-buffer riece-user-list-buffer
-       (unless (riece-frozen riece-user-list-buffer)
-         (set-window-start (get-buffer-window riece-user-list-buffer)
-                           (point-min)))))
-  (if (get-buffer-window riece-channel-list-buffer)
-      (with-current-buffer riece-channel-list-buffer
-       (unless (riece-frozen riece-channel-list-buffer)
-         (set-window-start (get-buffer-window riece-channel-list-buffer)
-                           (point-min))))))
-
 (defun riece-update-user-list-buffer ()
   (save-excursion
     (set-buffer riece-user-list-buffer)
@@ -352,22 +223,9 @@ PLIST accept :command-height, :user-list-width, and :channel-list-width."
     (with-current-buffer riece-channel-list-buffer
       (setq riece-redisplay-buffer t))))
 
-(defun riece-configure-windows-predicate ()
-  ;; The current channel is changed, and some buffers are visible.
-  (unless (equal riece-last-channel riece-current-channel)
-    (let ((buffers riece-buffer-list))
-      (catch 'found
-       (while buffers
-         (if (and (buffer-live-p (car buffers))
-                  (get-buffer-window (car buffers)))
-             (throw 'found t)
-           (setq buffers (cdr buffers))))))))
-
 (defun riece-redisplay-buffers (&optional force)
   (riece-update-buffers)
-  (if (or force
-         (funcall riece-configure-windows-predicate))
-      (funcall riece-configure-windows-function))
+  (riece-redraw-layout force)
   (run-hooks 'riece-redisplay-buffers-hook))
 
 (provide 'riece-display)