From 8bd05ae874a85ed75f9ef0b289506228e007da1b Mon Sep 17 00:00:00 2001 From: diluculo Date: Mon, 16 Jul 2018 20:06:37 +0900 Subject: [PATCH 1/2] Theme: Add TextEditor styles --- .../Controls/CodeEditor.cs | 58 +++++++++++- .../Resources/Resources.xaml | 93 +++++++++++++++++++ .../ViewModels/CodeEditorViewModel.cs | 55 +++++++++++ .../Views/CodeEditorView.xaml | 11 ++- src/Gemini/Themes/VS2013/BlueTheme.xaml | 15 ++- src/Gemini/Themes/VS2013/DarkTheme.xaml | 15 ++- src/Gemini/Themes/VS2013/LightTheme.xaml | 15 ++- 7 files changed, 254 insertions(+), 8 deletions(-) create mode 100644 src/Gemini.Modules.CodeEditor/Resources/Resources.xaml diff --git a/src/Gemini.Modules.CodeEditor/Controls/CodeEditor.cs b/src/Gemini.Modules.CodeEditor/Controls/CodeEditor.cs index 26d670ecb..f979ea728 100644 --- a/src/Gemini.Modules.CodeEditor/Controls/CodeEditor.cs +++ b/src/Gemini.Modules.CodeEditor/Controls/CodeEditor.cs @@ -1,3 +1,4 @@ +using System.Windows; using System.Windows.Media; using ICSharpCode.AvalonEdit; using ICSharpCode.AvalonEdit.Search; @@ -6,17 +7,58 @@ namespace Gemini.Modules.CodeEditor.Controls { public class CodeEditor : TextEditor { + #region LineNumber + + /// + /// The property. + /// + public static DependencyProperty LineNumberProperty = DependencyProperty.Register( + "LineNumber", + typeof(int), + typeof(CodeEditor), + new PropertyMetadata(default(int))); + + public int LineNumber + { + get { return (int)GetValue(LineNumberProperty); } + set { SetValue(LineNumberProperty, value); } + } + + #endregion LineNumber + + #region ColumnPosition + + /// + /// The property. + /// + public static DependencyProperty ColumnPositionProperty = DependencyProperty.Register( + "ColumnPosition", + typeof(int), + typeof(CodeEditor), + new PropertyMetadata(default(int))); + + public int ColumnPosition + { + get { return (int)GetValue(ColumnPositionProperty); } + set { SetValue(ColumnPositionProperty, value); } + } + + #endregion ColumnPosition + public CodeEditor() { ApplySettings(); - Loaded += (s, e) => SearchPanel.Install(this); - DocumentChanged += (s, e) => SearchPanel.Install(this); + + // Caret related + LineNumber = 1; + ColumnPosition = 1; + TextArea.Caret.PositionChanged += OnCaretPositionChanged; } public void ApplySettings() { FontFamily = new FontFamily("Consolas"); - FontSize = 12; + FontSize = 14; ShowLineNumbers = Properties.Settings.Default.ShowLineNumbers; WordWrap = Properties.Settings.Default.WordWrap; @@ -37,5 +79,15 @@ public void ApplySettings() Options.ShowTabs = Properties.Settings.Default.ShowTabs; } } + + #region Event Handlers + + private void OnCaretPositionChanged(object sender, System.EventArgs e) + { + LineNumber = TextArea.Caret.Line; + ColumnPosition = TextArea.Caret.Column; + } + + #endregion Event Handlers } } diff --git a/src/Gemini.Modules.CodeEditor/Resources/Resources.xaml b/src/Gemini.Modules.CodeEditor/Resources/Resources.xaml new file mode 100644 index 000000000..4f244ca67 --- /dev/null +++ b/src/Gemini.Modules.CodeEditor/Resources/Resources.xaml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gemini.Modules.CodeEditor/ViewModels/CodeEditorViewModel.cs b/src/Gemini.Modules.CodeEditor/ViewModels/CodeEditorViewModel.cs index cb2c7ae64..955176c25 100644 --- a/src/Gemini.Modules.CodeEditor/ViewModels/CodeEditorViewModel.cs +++ b/src/Gemini.Modules.CodeEditor/ViewModels/CodeEditorViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.ComponentModel.Composition; using System.IO; using System.Threading.Tasks; @@ -8,6 +9,7 @@ using Gemini.Framework.Threading; using Gemini.Modules.CodeEditor.Commands; using Gemini.Modules.CodeEditor.Views; +using Gemini.Modules.StatusBar; namespace Gemini.Modules.CodeEditor.ViewModels { @@ -27,12 +29,50 @@ public class CodeEditorViewModel : PersistedDocument, private string _originalText; private ICodeEditorView _view; + private IStatusBar _statusBar; + + private int _lineNumber = 0; + [DisplayName("Line Number")] + public int LineNumber + { + get { return _lineNumber; } + set + { + if (_lineNumber != value) + { + _lineNumber = value; + NotifyOfPropertyChange(() => LineNumber); + UpdateStatusBar(); + } + } + } + + private int _columnPosition = 0; + [DisplayName("Column Position")] + public int ColumnPosition + { + get { return _columnPosition; } + set + { + if (_columnPosition != value) + { + _columnPosition = value; + NotifyOfPropertyChange(() => ColumnPosition); + UpdateStatusBar(); + } + } + } + [ImportingConstructor] public CodeEditorViewModel(LanguageDefinitionManager languageDefinitionManager) { _languageDefinitionManager = languageDefinitionManager; + + _statusBar = IoC.Get(); } + #region Override methods + public override bool ShouldReopenOnStart { get { return true; } @@ -88,6 +128,8 @@ protected override Task DoSave(string filePath) return TaskUtility.Completed; } + #endregion Override methods + private void ApplyOriginalText() { if (_view == null) @@ -122,6 +164,19 @@ public void ApplySettings() _view?.ApplySettings(); } + #region StatusBar + + private void UpdateStatusBar() + { + if (_statusBar != null && _statusBar.Items.Count >= 3) + { + _statusBar.Items[1].Message = string.Format("Ln {0}", LineNumber); + _statusBar.Items[2].Message = string.Format("Col {0}", ColumnPosition); + } + } + + #endregion StatusBar + #region CommandHandlers void ICommandHandler.Update(Command command) { diff --git a/src/Gemini.Modules.CodeEditor/Views/CodeEditorView.xaml b/src/Gemini.Modules.CodeEditor/Views/CodeEditorView.xaml index 5ac77dda9..1d9c27c6e 100644 --- a/src/Gemini.Modules.CodeEditor/Views/CodeEditorView.xaml +++ b/src/Gemini.Modules.CodeEditor/Views/CodeEditorView.xaml @@ -1,4 +1,4 @@ - + + + + + - + diff --git a/src/Gemini/Themes/VS2013/BlueTheme.xaml b/src/Gemini/Themes/VS2013/BlueTheme.xaml index 4f5f1143f..26e742830 100644 --- a/src/Gemini/Themes/VS2013/BlueTheme.xaml +++ b/src/Gemini/Themes/VS2013/BlueTheme.xaml @@ -1,4 +1,4 @@ - @@ -170,6 +170,19 @@ + + + + + + + + + + + + + diff --git a/src/Gemini/Themes/VS2013/DarkTheme.xaml b/src/Gemini/Themes/VS2013/DarkTheme.xaml index 1d6dc3b54..cfaa78b07 100644 --- a/src/Gemini/Themes/VS2013/DarkTheme.xaml +++ b/src/Gemini/Themes/VS2013/DarkTheme.xaml @@ -1,4 +1,4 @@ - @@ -170,6 +170,19 @@ + + + + + + + + + + + + + diff --git a/src/Gemini/Themes/VS2013/LightTheme.xaml b/src/Gemini/Themes/VS2013/LightTheme.xaml index fd6f08be2..b6ecc776e 100644 --- a/src/Gemini/Themes/VS2013/LightTheme.xaml +++ b/src/Gemini/Themes/VS2013/LightTheme.xaml @@ -1,4 +1,4 @@ - @@ -170,6 +170,19 @@ + + + + + + + + + + + + + From 366bb48ea22258eb13413cd43748ffda2a2ee897 Mon Sep 17 00:00:00 2001 From: Jong Hyun Kim Date: Tue, 2 Nov 2021 11:30:30 +0900 Subject: [PATCH 2/2] Replace icons with outlines --- .../Resources/Icons/ShowEndOfLine.png | Bin 226 -> 303 bytes .../Resources/Icons/ShowLineNumbers.png | Bin 362 -> 468 bytes .../Resources/Icons/ShowSpaces.png | Bin 286 -> 282 bytes .../Resources/Icons/ShowTabs.png | Bin 389 -> 381 bytes .../Resources/Icons/WordWrap.png | Bin 200 -> 194 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/Gemini.Modules.CodeEditor/Resources/Icons/ShowEndOfLine.png b/src/Gemini.Modules.CodeEditor/Resources/Icons/ShowEndOfLine.png index dfc491c5c7b895b67a599d43e17a42c21df0d161..69a4fede146e4663457edd3d1f89b58a494769de 100644 GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2co&H|6fVg?3oArNM~bhqvgQ1GFr zi(`mIZ}Ol2|LvKVHgrn-wXgqc^yBC2>CAqt3eyt~+t>Ze`SJ1d^HzEL`hWIyUtauw zeSO`3_KgcI7$f<)`DW|q+}#mae|J|YkAB>Kw~3z%3KLK0Y6Urn9X5FKe0@Bx0`s!7 zb2!BxC#0tfJa~NAK!9ySYvitQ2iP`l-l!^&%Czxh x-3y7P?HWLLi|d_q1FB?O#G}Y%U|_(&@G-Vr*lx#z`9RMyc)I$ztaD0e0stP>cuxQT literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!E#R*#}EtuWQl?U97{JcPMD)4P~220aDeZ~ za|NG22}%P0k2f|qO6b2}NlM{8-LOOc)UgX^Se8y~l$+AlsP0h1e<;O*cj-fh*^COj zF3dS>TbMt_a!fWjkj8Lgrrd|C>+W|Nr>;(*Y(&2(v(KFL?gxZ-3XZ*9^Pf|72KdE6!jb!vPW(U|?V{ zz~=~dHnsyW?`+^@XY5zyV+9+61PngBf4~3I`SVx}uyb+(QH(55(;hG|{5qIrC2T+S z;TIHzAOkvkdhi(n_YNp9?a|ciXJBAh2vP`Bj0-Tq#4kMg!JxhTA($O~_$9-l)9*mc z2kdNYjQB7EaukCC@@k|!UK?=&q$qCq@$={Z`>(%&qW1$R%889)aEkr;>sQ0`Pk-wp zcRpiy{pTNpB@ZjZ9ABxA3=9kk#6&U75Kww}aN)@heps07@s?qb>z%G&GV+Oh81u;vV~B-+G6VC~|EfG$|Nk4G`18DlLx6uq zgOso2KVzGQPo8W&0kat2H0ATe@c2vYcXsV+xWRPj2&dlz69q%V!b7L0>z5uVvS`?` zz5c2;$hf*V(Px6kV2jreliNmm`# z@IMt~@kt1px{z0*WB)T6l{an^LB{Ts5 D5FLhG diff --git a/src/Gemini.Modules.CodeEditor/Resources/Icons/ShowSpaces.png b/src/Gemini.Modules.CodeEditor/Resources/Icons/ShowSpaces.png index 556711976804bbead4e1c9cfb5c3be5a97953207..d73babc82fdabfb9abfd0f2074c5c29d1d22f7b4 100644 GIT binary patch literal 282 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2co&H|6fVg?3oArNM~bhqvgQ1FbW zi(`mIZ}Ol2|LvKVHgqNlyYWgsY1{DU&sXn;#>RsTo^KefrEfFW%&PnMi#14}LHx(Z z&&v;Yi|hY;e{0|0|6jAO|NsBv=Vrz!3?CoL+tzopr0LDXkZ~y=R literal 286 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!Ofm7jv*HQZ_gj(Vhj{%|LCaM+SQ%B zwr$pK-TEhP`>e__o)mxKFl+IfK!-hC?{*|E;eINfGvTN}bjboSv#EA|i4D_PU3CiG zxTBW!nO%LAX?E8z#^4~Q?`3#<}elF{r5}E)p)^I5R diff --git a/src/Gemini.Modules.CodeEditor/Resources/Icons/ShowTabs.png b/src/Gemini.Modules.CodeEditor/Resources/Icons/ShowTabs.png index 5f24c34b52019ad6af1fdcb9aad2eb60732ee9e5..43b18ba182c8454acc730365b222209df3c55c33 100644 GIT binary patch literal 381 zcmV-@0fPRCP)Ccfte)2~kmGgZ$A0R^a@ZGxl?5&n7A+pawCBiijdyLX=Jd0OXPnh9)Kl zr)#PH(vYnTBS zp@ExEtal8Un3(vGTyPO;;Rh5|#3VLQTKMtv=Y=0Xe+s}78&r&NVnZ@00A>I-JV=TH b1_lNIq;fV$;j*uW00000NkvXXu0mjf_N=7i literal 389 zcmV;00eb$4P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0UAj}K~y+T?U21n z!(bGKlSsf!Qo+R`Kcdd!CL!?>q=PpiDo8=-=A^hec_)FSfeijk;-)dNZbdq%I3y%K zNj|C{cnN*r@Sa28^L{5)<|qq7TYTSNbsXoyvaGK>&tI6gY}>wKeqf#mn}igA=>zk& zs;YhTbu=2?60oajS|7d7vg}=0XGj4JgoKzk3E4+e!!WLkqS#^HGfnf3->1Ubq6w7< z!*E#F^$qQSItu<^v%gB j%STC)e0Q!nGK%s8_i=O}Heu9000000NkvXXu0mjff3c>4 diff --git a/src/Gemini.Modules.CodeEditor/Resources/Icons/WordWrap.png b/src/Gemini.Modules.CodeEditor/Resources/Icons/WordWrap.png index 1a1d854cd15d99e93fa2a3e509f1e64ca6f9b174..24748ab9687122a8f7e4f6766f2a8a639a2d388e 100644 GIT binary patch delta 166 zcmV;X09pUY0m1>0B!3BTNLh0L01m?d01m?e$8V@)0001VNkl*gj&Hw-a delta 172 zcmV;d08{_M0muQ6B!32COGiWi{{a60|De66lK=n!eMv+?R5*>*(6I@FP#DDVpJI_Q zQdx)tBu%EsBw0Ww5PQe55z?ecmjPVE<^@7X^BzI*nvd_`&mG6^m4$o5DUzMg<^S!o zg;F+{G2jU)8(eTloxpmBKG4TBXutjp2PlH^Yl8`0fE!f7FC}rrHKxI*Mx61Af!c(i am9zlSLJmo^Mokd_0000