diff --git a/CHANGELOG.md b/CHANGELOG.md index 58fe024..791572d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Icon for spacemacs buffer. - Icon for Isearch (from Font Awesome) - Icon for Org-Agenda (From Font Awesome) +- Icon for Powershell +- Icon for Windows cmd +- Icon for MSYS shell +- Icon for Cygwin shell - Added option mode-icons-line-height-adjust to allow imagmagick to adjust icons up or down a bit compared to what emacs returns as the mode-line height. diff --git a/icons/cmd.xpm b/icons/cmd.xpm new file mode 100644 index 0000000..e4348dc --- /dev/null +++ b/icons/cmd.xpm @@ -0,0 +1,46 @@ +/* XPM */ +static char * d:\EmacsPortable_App\Data\src\mode_icons\icons\cmd_xpm[] = { +"16 16 27 1", +" g None", +". g #FFFFFF", +"+ g #000000", +"@ g #505050", +"# g #989898", +"$ g #6B6B6B", +"% g #E8E8E8", +"& g #111111", +"* g #F6F6F6", +"= g #080808", +"- g #FDFDFD", +"; g #BBBBBB", +"> g #353535", +", g #8D8D8D", +"' g #5A5A5A", +") g #5F5F5F", +"! g #7E7E7E", +"~ g #323232", +"{ g #A3A3A3", +"] g #FAFAFA", +"^ g #0A0A0A", +"/ g #FBFBFB", +"( g #070707", +"_ g #C3C3C3", +": g #646464", +"< g #A8A8A8", +"[ g #606060", +"................", +".++++++++++++++.", +".++++++++++++++.", +"................", +".++++++++++++++.", +".++++++++++++++.", +".+@#$+++%&+++++.", +".+*=-+++;>+++++.", +".+.+++++,'+++++.", +".+.+++.+)!+++++.", +".+.+.+++~{+++++.", +".+]^/+++(_+++++.", +".+:<[+.++_+++++.", +".++++++++++...;.", +".++++++++++++++.", +"................"}; diff --git a/icons/cygwin.xpm b/icons/cygwin.xpm new file mode 100644 index 0000000..a2379c0 --- /dev/null +++ b/icons/cygwin.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * d:\EmacsPortable_App\Data\src\mode_icons\icons\cygwin_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #00FF00", +" ", +" ........... ", +" .............. ", +" .......... ", +" .... ", +" ... ", +" ... +++++ ", +" ... ++++++++ ", +" ... ++++++++ ", +" ... +++++ ", +" ... ", +" .... ", +" .......... ", +" .............. ", +" ........... ", +" "}; diff --git a/icons/msys.xpm b/icons/msys.xpm new file mode 100644 index 0000000..d246d28 --- /dev/null +++ b/icons/msys.xpm @@ -0,0 +1,146 @@ +/* XPM */ +static char * d:\EmacsPortable_App\Data\src\mode_icons\icons\msys_xpm[] = { +"16 16 127 2", +" c None", +". c #7A536A", +"+ c #4E92CF", +"@ c #A4BDD8", +"# c #89545B", +"$ c #536B9B", +"% c #5D9CD0", +"& c #9DC2E6", +"* c #676086", +"= c #3F89CC", +"- c #89C0E6", +"; c #987984", +"> c #6A4253", +", c #4585C7", +"' c #5DA5D9", +") c #A8B7D4", +"! c #7C3C4A", +"~ c #4B94D4", +"{ c #4D8ACA", +"] c #75B3DF", +"^ c #B4B0C4", +"/ c #5D82B5", +"( c #56A0D7", +"_ c #6FAFDE", +": c #B0BDD6", +"< c #657AA7", +"[ c #93B7DA", +"} c #6280BC", +"| c #7BA4D5", +"1 c #C4DCF0", +"2 c #7A556D", +"3 c #69A9DE", +"4 c #5E82C2", +"5 c #8ABBE1", +"6 c #BCC8DD", +"7 c #66353E", +"8 c #8BAFD8", +"9 c #ABA3B5", +"0 c #7875A0", +"a c #83A4D5", +"b c #D7F3FF", +"c c #622122", +"d c #778FB9", +"e c #AFBACF", +"f c #707BB0", +"g c #95BDE2", +"h c #D0E8F9", +"i c #9B89A3", +"j c #C2E1F9", +"k c #864145", +"l c #827091", +"m c #8FA6D7", +"n c #D9F0FD", +"o c #AB8893", +"p c #B8D7EF", +"q c #82444D", +"r c #7B85B1", +"s c #A0BFE3", +"t c #DCF2FD", +"u c #99606A", +"v c #B6D1EF", +"w c #C0A3AA", +"x c #8D5F73", +"y c #9DABDC", +"z c #D1E4F3", +"A c #D5E8F6", +"B c #C0A2AA", +"C c #868AB2", +"D c #B3C6E6", +"E c #E1F4FD", +"F c #B08D91", +"G c #ABA9C5", +"H c #DBE4EF", +"I c #724344", +"J c #773231", +"K c #A6A9D9", +"L c #D1E0F1", +"M c #E3ECF3", +"N c #784848", +"O c #9C86AA", +"P c #B2B6DF", +"Q c #E3F2FA", +"R c #DDD7D8", +"S c #937379", +"T c #ECF9FF", +"U c #C6AAAC", +"V c #A7829D", +"W c #D9E0F0", +"X c #DBD1D4", +"Y c #77363B", +"Z c #B6B6DC", +"` c #BA9AA6", +" . c #EDEFF3", +".. c #8C6D6E", +"+. c #B6969A", +"@. c #B69196", +"#. c #5D2A2D", +"$. c #D6CEDA", +"%. c #84494C", +"&. c #4A2424", +"*. c #965253", +"=. c #E9DEDF", +"-. c #A57379", +";. c #57191A", +">. c #804446", +",. c #A48B8F", +"'. c #B39193", +"). c #7C3434", +"!. c #E1D4D7", +"~. c #A26F72", +"{. c #531111", +"]. c #F4EEF1", +"^. c #914142", +"/. c #E4D7D9", +"(. c #CFB1B6", +"_. c #5C1E1E", +":. c #9C5659", +"<. c #BFA4A5", +"[. c #B7888C", +"}. c #C69FA4", +"|. c #602F2F", +"1. c #D6BDC1", +"2. c #220000", +"3. c #B79094", +"4. c #BB8E93", +"5. c #411D1D", +"6. c #A97378", +" ", +" . + @ # $ % & ", +" * = - ; > , ' ) ", +" ! ~ { ] ^ / ( _ : ", +" < [ } | 1 2 3 4 5 6 ", +" 7 8 9 0 a b c d e f g h ", +" i j k l m n o p q r s t ", +" u v w x y z A B C D E F ", +" G H I J K L M N O P Q R ", +"S T U V W X Y Z ` ...", +"+.@. #.$.%. &.*.=.-. ", +" ;.>.,.'.).!.~. ", +" {.].^./.(._.:.<. ", +" [.}.|.1. ", +" 2.3.4.5.6. ", +" "}; diff --git a/icons/powershell.xpm b/icons/powershell.xpm new file mode 100644 index 0000000..3755955 --- /dev/null +++ b/icons/powershell.xpm @@ -0,0 +1,197 @@ +/* XPM */ +static char * d:\EmacsPortable_App\Data\src\mode_icons\icons\powershell_xpm[] = { +"16 16 178 2", +" c None", +". c #13B5D8", +"+ c #13B6D9", +"@ c #14B6D9", +"# c #12B4D7", +"$ c #13B2D5", +"% c #12B1D3", +"& c #13AFD2", +"* c #14ADD0", +"= c #14ABCE", +"- c #14A9CC", +"; c #14A8CA", +"> c #14A6C8", +", c #14A4C5", +"' c #12BFE3", +") c #A2E6F5", +"! c #52CAE3", +"~ c #10B8DC", +"{ c #13B6DA", +"] c #14B4D7", +"^ c #14B1D4", +"/ c #14AFD2", +"( c #14ADCF", +"_ c #14AACD", +": c #14A6C7", +"< c #13BEE2", +"[ c #12BDE1", +"} c #9BDDEC", +"| c #FFFEFE", +"1 c #21B8D9", +"2 c #13B4D7", +"3 c #14B2D5", +"4 c #14A9CB", +"5 c #14A2C4", +"6 c #13B3D6", +"7 c #13BBDF", +"8 c #0AB5D9", +"9 c #CDEBF2", +"0 c #C3E8F1", +"a c #0DAFD3", +"b c #14B0D3", +"c c #14AED0", +"d c #14A7C9", +"e c #14A4C6", +"f c #14A1C2", +"g c #13B7DB", +"h c #13BADE", +"i c #12B8DB", +"j c #1BB2D4", +"k c #F2F8FA", +"l c #83D0E3", +"m c #12AED1", +"n c #14ACCE", +"o c #14A5C7", +"p c #13A3C4", +"q c #159FC0", +"r c #13B8DB", +"s c #13B5D9", +"t c #11B4D7", +"u c #6DC9DE", +"v c #F4FAFC", +"w c #2BAFCC", +"x c #14AACC", +"y c #13A3C5", +"z c #12BBDF", +"A c #13B9DC", +"B c #12B6DA", +"C c #0EB0D4", +"D c #C4EAF3", +"E c #E6F2F6", +"F c #1CA1C0", +"G c #14A1C3", +"H c #159FC1", +"I c #13B9DD", +"J c #12B7DA", +"K c #23B7D8", +"L c #C8ECF4", +"M c #D7ECF2", +"N c #33A7C3", +"O c #13AACD", +"P c #13A4C6", +"Q c #14A2C3", +"R c #159DBF", +"S c #13ADCF", +"T c #1AB5D7", +"U c #C6EAF4", +"V c #CFE5EB", +"W c #25A7C5", +"X c #05A4C8", +"Y c #08A3C6", +"Z c #09A0C4", +"` c #14A3C4", +" . c #15A0C2", +".. c #149EBF", +"+. c #159BBC", +"@. c #16B4D7", +"#. c #DCF1F7", +"$. c #CDE9F1", +"%. c #1BA3C2", +"&. c #56C4DD", +"*. c #CDEFF7", +"=. c #C9ECF6", +"-. c #B1E2EE", +";. c #14A0C2", +">. c #149EC0", +",. c #159CBE", +"'. c #159ABB", +"). c #13B1D4", +"!. c #17B2D5", +"~. c #9DCFDC", +"{. c #1FA7C6", +"]. c #12ABCD", +"^. c #3DB7D3", +"/. c #80C6D7", +"(. c #7EC4D7", +"_. c #70BDD0", +":. c #149FC1", +"<. c #159DBE", +"[. c #159ABC", +"}. c #1599BA", +"|. c #16B5D7", +"1. c #16B2D5", +"2. c #16AFD2", +"3. c #16ABCD", +"4. c #16A9CA", +"5. c #15A6C8", +"6. c #15A4C6", +"7. c #15A2C3", +"8. c #16A0C1", +"9. c #169EBE", +"0. c #169BBC", +"a. c #1699B9", +"b. c #AEC2C5", +"c. c #AABFC2", +"d. c #A9BEC0", +"e. c #A7BCBE", +"f. c #A8BDC0", +"g. c #A6BBBE", +"h. c #A5BABD", +"i. c #A3B8BB", +"j. c #AABDC0", +"k. c #9FB5B7", +"l. c #9DB3B5", +"m. c #99AEB1", +"n. c #B9CED1", +"o. c #B5C9CC", +"p. c #B4C8CB", +"q. c #B3C7CA", +"r. c #637A7E", +"s. c #5F7679", +"t. c #5F7579", +"u. c #5E7579", +"v. c #6E8387", +"w. c #A7BBBF", +"x. c #5C7377", +"y. c #A5B8BA", +"z. c #B8CDD0", +"A. c #B6CACD", +"B. c #9EB4B7", +"C. c #9CB3B6", +"D. c #9AB1B4", +"E. c #99AFB3", +"F. c #9DB2B5", +"G. c #8EA4A8", +"H. c #94ACAF", +"I. c #91A9AD", +"J. c #92A6A8", +"K. c #A3B6B8", +"L. c #A0B4B6", +"M. c #9FB2B5", +"N. c #9DB1B3", +"O. c #9CAFB1", +"P. c #9AAEB0", +"Q. c #99ACAF", +"R. c #96AAAC", +"S. c #90A4A6", +"T. c #94A9AA", +"U. c #93A7AA", +" . + @ # $ % & * = - ; > , ", +" ' ' ) ! ~ { ] ^ / ( _ ; : ", +" < [ } | 1 2 3 / ( _ 4 > 5 ", +" 6 < 7 8 9 0 a b c = 4 d e f ", +" g 7 h i j k l m n 4 ; o p q ", +" [ h r s t u v w x ; o y f ", +" z A B ] C D E F ; > e G H ", +" I J 2 K L M N O d P Q H R ", +" S i . T U V W X Y Z ` ...+. ", +" & s @.#.$.%.&.*.=.-.;.>.,.'. ", +" ).] !.~.{.].^./.(._.:.<.[.}. ", +" |.1.2.( 3.4.5.6.7.8.9.0.a. ", +" b.c.d.e.c.f.g.h.i.j.k.l.m. ", +" n.o.p.q.r.s.t.u.v.w.x.x.m. ", +"y.z.A.p.q.B.C.D.E.F.G.H.I.J. ", +" K.L.M.N.N.O.P.Q.R.S.T.U. "}; diff --git a/mode-icons.el b/mode-icons.el index d89f1e4..1e299f2 100644 --- a/mode-icons.el +++ b/mode-icons.el @@ -207,6 +207,11 @@ This was stole/modified from `c-save-buffer-state'" ("\\`Spacemacs buffer\\'" "spacemacs" png) ("\\` ?emoji\\'" "emoji" png) ("\\`Org-Agenda" #xf046 FontAwesome) + ("\\`PS\\'" "powershell" xpm) + (mode-icons-powershell-p "powershell" xpm) + (mode-icons-cmd-p "cmd" xpm-bw) + (mode-icons-msys-p "msys" xpm) + (mode-icons-cygwin-p "cygwin" xpm) (read-only #xf023 FontAwesome) (writable #xf09c FontAwesome) (save #xf0c7 FontAwesome) @@ -281,6 +286,23 @@ without the extension. And the third being the type of icon." (symbol :tag "Font")))) :group 'mode-icons) +(defun mode-icons-powershell-p (&optional match) + "Is the current mode a powershell process?" + (let ((proc (get-buffer-process (current-buffer)))) + (and proc (string-match-p (or match "powershell") (car (process-command proc)))))) + +(defun mode-icons-cmd-p () + "Is the current mode a CMD shell?" + (mode-icons-powershell-p "cmdproxy")) + +(defun mode-icons-cygwin-p () + "Is the current mode a CMD shell?" + (mode-icons-powershell-p "cygwin")) + +(defun mode-icons-msys-p () + "Is the current mode a CMD shell?" + (mode-icons-powershell-p "msys")) + (defvar mode-icons-get-xpm-string (make-hash-table :test 'equal)) (defun mode-icons-get-xpm-string (icon-path) "Get XPM file contents for ICON-PATH. @@ -1230,29 +1252,37 @@ ACTIVE is a flag to tell if the current window is active." (defvar mode-icons-get-icon-spec (make-hash-table :test 'equal) "Hash table of icon-specifications.") -(defun mode-icons-get-icon-spec (mode) +(defun mode-icons-get-icon-spec (mode &optional is-major-mode-p) "Get icon spec for MODE based on regular expression." (or (gethash mode mode-icons-get-icon-spec) - (puthash mode (let* (case-fold-search - (icon-spec (catch 'found-mode - (dolist (item mode-icons) - (when (and (mode-icons-supported-p item) - (or - (and - (stringp (car item)) - (stringp mode) - (string-match-p (car item) mode)) - (and - (symbolp (car item)) - (symbolp mode) - (eq mode (car item))))) - (throw 'found-mode item))) - nil))) - (when (and icon-spec (eq (nth 2 icon-spec) 'emoji) - (file-exists-p (mode-icons--get-emoji-xpm-file icon-spec))) - (setq icon-spec (list (nth 0 icon-spec) (mode-icons--get-emoji-xpm-file icon-spec t) 'xpm))) - icon-spec) - mode-icons-get-icon-spec))) + (let* (case-fold-search + (ignore-cache nil) + (icon-spec (catch 'found-mode + (dolist (item mode-icons) + (when (and (mode-icons-supported-p item) + (or + (and + (stringp (car item)) + (stringp mode) + (string-match-p (car item) mode)) + (and + (symbolp (car item)) + (symbolp mode) + (eq mode (car item))) + (and + is-major-mode-p + (symbolp (car item)) + (functionp (car item)) + (and (ignore-errors (funcall (car item))) + (setq ignore-cache t))))) + (throw 'found-mode item))) + nil))) + (when (and icon-spec (eq (nth 2 icon-spec) 'emoji) + (file-exists-p (mode-icons--get-emoji-xpm-file icon-spec))) + (setq icon-spec (list (nth 0 icon-spec) (mode-icons--get-emoji-xpm-file icon-spec t) 'xpm))) + (unless ignore-cache + (puthash mode icon-spec mode-icons-get-icon-spec)) + icon-spec))) (defcustom mode-icons-show-mode-name nil "Show Icon and `mode-name'." @@ -1277,7 +1307,7 @@ icon as well." FACE represents the face used when the icon is a xpm-bw image. ACTIVE represents if the window is active." (let* ((mode-name (format-mode-line mode)) - (icon-spec (mode-icons-get-icon-spec mode-name)) + (icon-spec (mode-icons-get-icon-spec mode-name t)) (face (mode-icons--get-face face active)) ret) (when (and (not icon-spec) mode-icons-use-default-icon)