From 3615bdd5bcf28674861f1bb7aa9b1ca5fa6d57a6 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 13 Jul 2023 19:19:57 +0800 Subject: [PATCH] Add a Doc View tool bar * etc/NEWS: Announce the new tool bar. * etc/images/last-page.xpm: * etc/images/last-page.pbm: New images. Mirrored from next-page.xpm. * lisp/doc-view.el (doc-view-menu): Use `doc-view-new-search' instead of an anonymous function. (doc-view-tool-bar-map): New keymap. (doc-view-search): Update the tool bar after initiating a search. (doc-view-new-search): New command. (doc-view-mode): Set the tool bar map appropriately. --- etc/NEWS | 6 ++ etc/images/last-page.pbm | Bin 0 -> 81 bytes etc/images/last-page.xpm | 122 +++++++++++++++++++++++++++++++++++++++ lisp/doc-view.el | 54 ++++++++++++++++- 4 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 etc/images/last-page.pbm create mode 100644 etc/images/last-page.xpm diff --git a/etc/NEWS b/etc/NEWS index db4fa9f403e..8150c71af11 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -360,6 +360,12 @@ this new face when DocView displays documents, customize this face to restore the colors you were used to, or to get colors more to your liking. +--- +*** DocView buffers now display a new tool bar. +This tool bar contains options for searching and navigating within the +document, replacing the incompatible items for incremental search and +editing within the default tool bar displayed in the past. + ** Shortdoc +++ diff --git a/etc/images/last-page.pbm b/etc/images/last-page.pbm new file mode 100644 index 0000000000000000000000000000000000000000..d25ce022183c3db13632e48ec787bbaefe879cca GIT binary patch literal 81 zcmWGA;W9E&Ff!p{00a5Qe++oo3>d&jfz2R+&ENr>;Xe=wVgp4O5Xk=fKl}fG7-S$? Gp(Frs9}dg_ literal 0 HcmV?d00001 diff --git a/etc/images/last-page.xpm b/etc/images/last-page.xpm new file mode 100644 index 00000000000..5704143aa2e --- /dev/null +++ b/etc/images/last-page.xpm @@ -0,0 +1,122 @@ +/* XPM */ +static char *last_page[] = { +/* columns rows colors chars-per-pixel */ +"24 24 92 1 ", +" c None", +". c black", +"X c gray15", +"o c #2F4050", +"O c #344353", +"+ c #3B4F63", +"@ c #384F66", +"# c #3A5067", +"$ c #3C5064", +"% c #3C5065", +"& c #3E5166", +"* c #3F5266", +"= c #3A5168", +"- c #3B5269", +"; c #3D526A", +": c #3E546A", +"> c #3F556B", +", c #3E5975", +"< c #3F5A76", +"1 c #464646", +"2 c #494949", +"3 c #405367", +"4 c #405468", +"5 c #40566C", +"6 c #41576D", +"7 c #42586E", +"8 c #44586F", +"9 c #45596F", +"0 c #465B70", +"q c #415B77", +"w c #425C78", +"e c #435E79", +"r c #445F7A", +"t c #46607B", +"y c #47617B", +"u c #47617C", +"i c #48627D", +"p c #49637D", +"a c #4B647E", +"s c #4C647F", +"d c #4C657F", +"f c gray38", +"g c #6A6A6A", +"h c #616A73", +"j c #68727D", +"k c #7C7C7C", +"l c #4E6780", +"z c #4F6881", +"x c #506982", +"c c #526A83", +"v c #556D85", +"b c #5B7289", +"n c #7D8185", +"m c #77838F", +"M c #868788", +"N c #888888", +"B c #8B8B8B", +"V c #8F9296", +"C c #8F9396", +"Z c #8F9397", +"A c #909397", +"S c #959595", +"D c #91969C", +"F c #91979C", +"G c #92979C", +"H c #92979D", +"J c #9C9FA1", +"K c #9D9FA2", +"L c #A2A3A4", +"P c #A6A6A6", +"I c #ACACAC", +"U c gray68", +"Y c #B0B0B0", +"T c #B2B2B2", +"R c gray71", +"E c #B6B6B6", +"W c gray75", +"Q c #C5C5C5", +"! c gray79", +"~ c gray80", +"^ c LightGray", +"/ c #D6D6D6", +"( c #D8D8D8", +") c #DADADA", +"_ c #DEDEDE", +"` c gray89", +"' c #E5E5E5", +"] c #E6E6E6", +"[ c #EEEEEE", +"{ c #F2F2F2", +"} c #F6F6F6", +"| c white", +/* pixels */ +" ", +" ", +" ........ ........ ", +" .vU/_][`!N2gNT~)]{|b. ", +" .@T/_][}||PUTW~)]{|t. ", +" .#T/_][}`|PUTW~)]{|t. ", +" .-T/_][).|PUTW~)]{|t. ", +" .-T/_]^..|PUTW~)]{|t. ", +" .;T/_~...|PUTW~)]{|u. ", +" .>T/Q.....X1fkSR]{|i. ", +" .>T/_~...|PUTW~)]{|i. ", +" .5T/_]^..|PUTW~)]{|a. ", +" .5T/_][).|PUTW~)]{|d. ", +" .7T/_][}`|PUTW~)]{|d. ", +" .8T/_][}||PUTW~)]{|l. ", +" .8R/_][}||PUTW~)]{|z. ", +" .0MAZZZZZKPLHHHHHKmc. ", +" .O43&&&&+hnjtrwwq< (doc-view-current-page) 1) + :help "Move to the next page.") + (tool-bar-local-item-from-menu 'doc-view-next-page "next-page" + map doc-view-mode-map :vert-only t + :enable '(< (doc-view-current-page) + (doc-view-last-page-number)) + :help "Move to the next page.") + map) + "Like the default `tool-bar-map', but with additions for DocView.") + ;;;; Navigation Commands (defun doc-view-last-page-number () @@ -1863,7 +1902,16 @@ If BACKWARD is non-nil, jump to the previous match." ;; We must convert to TXT first! (if doc-view--current-converter-processes (message "DocView: please wait till conversion finished.") - (doc-view-doc->txt txt (lambda () (doc-view-search nil)))))))) + (doc-view-doc->txt txt (lambda () (doc-view-search nil)))))) + ;; Update the tool bar items. + (force-mode-line-update))) + +(defun doc-view-new-search () + "Initiate a new search query. +Prompt for a string, then search for its appearances within +the document text." + (interactive) + (doc-view-search t nil)) (defun doc-view-search-next-match (arg) "Go to the ARGth next matching page." @@ -2238,6 +2286,8 @@ toggle between displaying the document or editing it as text. major-mode 'doc-view-mode) (doc-view-imenu-setup) (doc-view-initiate-display) + ;; Replace the tool bar map with `doc-view-tool-bar-map'. + (setq-local tool-bar-map doc-view-tool-bar-map) ;; Switch off view-mode explicitly, because doc-view-mode is the ;; canonical view mode for PDF/PS/DVI files. This could be ;; switched on automatically depending on the value of