diff options
| author | Juri Linkov | 2019-09-03 22:55:13 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-09-03 22:55:13 +0300 |
| commit | a365251d01f553a329b6ade5b8a9dd93099caf41 (patch) | |
| tree | 7bfad7f767f2871726df1a80122f467da159186d /lisp | |
| parent | c2ab5e8cf3654e3e13083fb2203502d5d5f49dc6 (diff) | |
| download | emacs-a365251d01f553a329b6ade5b8a9dd93099caf41.tar.gz emacs-a365251d01f553a329b6ade5b8a9dd93099caf41.zip | |
Text-mode display of the tab-bar and emulation of clicking on a tty.
* lisp/tab-bar.el (tab-bar-mouse): New command bound to mouse-1 on [tab-bar].
* lisp/xt-mouse.el (xterm-mouse-event): Use `tab-bar' when clicking
on the tab-bar that is on the second row below menu-bar.
* src/frame.c (set_tab_bar_lines): New function.
(frame_windows_min_size): Add FRAME_TAB_BAR_LINES.
(make_initial_frame): Call set_tab_bar_lines.
(store_frame_param): Call set_tab_bar_lines for Qtab_bar_lines prop.
(Fframe_parameters): Call store_in_alist for Qtab_bar_lines.
* src/xdisp.c (display_tab_bar): New function.
(redisplay_window): Call display_tab_bar when `FRAME_WINDOW_P (f)'
is NULL on a tty.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/tab-bar.el | 27 | ||||
| -rw-r--r-- | lisp/xt-mouse.el | 8 |
2 files changed, 31 insertions, 4 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 1819d44ac20..f596bdb0a4f 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el | |||
| @@ -49,7 +49,8 @@ | |||
| 49 | (defface tab-bar | 49 | (defface tab-bar |
| 50 | '((default | 50 | '((default |
| 51 | :box (:line-width 1 :style released-button) | 51 | :box (:line-width 1 :style released-button) |
| 52 | :foreground "black") | 52 | :foreground "black" |
| 53 | :background "white") | ||
| 53 | (((type x w32 ns) (class color)) | 54 | (((type x w32 ns) (class color)) |
| 54 | :background "grey75") | 55 | :background "grey75") |
| 55 | (((type x) (class mono)) | 56 | (((type x) (class mono)) |
| @@ -97,7 +98,27 @@ | |||
| 97 | (global-set-key [(control shift iso-lefttab)] 'tab-bar-switch-to-prev-tab) | 98 | (global-set-key [(control shift iso-lefttab)] 'tab-bar-switch-to-prev-tab) |
| 98 | (global-set-key [(control tab)] 'tab-bar-switch-to-next-tab))) | 99 | (global-set-key [(control tab)] 'tab-bar-switch-to-next-tab))) |
| 99 | 100 | ||
| 100 | ;;;###autoload | 101 | (defun tab-bar-mouse (event) |
| 102 | "Text-mode emulation of switching tabs on the tab-bar. | ||
| 103 | This command is used when you click the mouse in the tab-bar | ||
| 104 | on a console which has no window system but does have a mouse." | ||
| 105 | (interactive "e") | ||
| 106 | (let* ((x-position (car (posn-x-y (event-start event)))) | ||
| 107 | (keymap (lookup-key (cons 'keymap (nreverse (current-active-maps))) [tab-bar])) | ||
| 108 | (column 0)) | ||
| 109 | (when x-position | ||
| 110 | (unless (catch 'done | ||
| 111 | (map-keymap | ||
| 112 | (lambda (_key binding) | ||
| 113 | (when (eq (car-safe binding) 'menu-item) | ||
| 114 | (when (> (+ column (length (nth 1 binding))) x-position) | ||
| 115 | (call-interactively (nth 2 binding)) | ||
| 116 | (throw 'done t)) | ||
| 117 | (setq column (+ column (length (nth 1 binding)) 1)))) | ||
| 118 | keymap)) | ||
| 119 | ;; Clicking anywhere outside existing tabs will add a new tab | ||
| 120 | (tab-bar-add-tab))))) | ||
| 121 | |||
| 101 | ;; Used in the Show/Hide menu, to have the toggle reflect the current frame. | 122 | ;; Used in the Show/Hide menu, to have the toggle reflect the current frame. |
| 102 | (defun toggle-tab-bar-mode-from-frame (&optional arg) | 123 | (defun toggle-tab-bar-mode-from-frame (&optional arg) |
| 103 | "Toggle tab bar on or off, based on the status of the current frame. | 124 | "Toggle tab bar on or off, based on the status of the current frame. |
| @@ -152,7 +173,7 @@ Return its existing value or a new value." | |||
| 152 | "Generate an actual keymap from `tab-bar-map', without caching." | 173 | "Generate an actual keymap from `tab-bar-map', without caching." |
| 153 | (let ((i 0)) | 174 | (let ((i 0)) |
| 154 | (append | 175 | (append |
| 155 | '(keymap) | 176 | '(keymap (mouse-1 . tab-bar-mouse)) |
| 156 | (mapcan | 177 | (mapcan |
| 157 | (lambda (tab) | 178 | (lambda (tab) |
| 158 | (setq i (1+ i)) | 179 | (setq i (1+ i)) |
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index b53174b7bd5..5464da25009 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el | |||
| @@ -253,7 +253,13 @@ which is the \"1006\" extension implemented in Xterm >= 277." | |||
| 253 | (top (nth 1 ltrb)) | 253 | (top (nth 1 ltrb)) |
| 254 | (posn (if w | 254 | (posn (if w |
| 255 | (posn-at-x-y (- x left) (- y top) w t) | 255 | (posn-at-x-y (- x left) (- y top) w t) |
| 256 | (append (list nil 'menu-bar) | 256 | (append (list nil (if (and tab-bar-mode |
| 257 | (or (not menu-bar-mode) | ||
| 258 | ;; The tab-bar is on the | ||
| 259 | ;; second row below menu-bar | ||
| 260 | (eq (cdr (nth 6 (posn-at-x-y x y))) 1))) | ||
| 261 | 'tab-bar | ||
| 262 | 'menu-bar)) | ||
| 257 | (nthcdr 2 (posn-at-x-y x y))))) | 263 | (nthcdr 2 (posn-at-x-y x y))))) |
| 258 | (event (list type posn))) | 264 | (event (list type posn))) |
| 259 | (setcar (nthcdr 3 posn) timestamp) | 265 | (setcar (nthcdr 3 posn) timestamp) |