diff --git a/.gitignore b/.gitignore index 8d5d458..e607174 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,10 @@ __history/ # Castalia statistics file *.stat +*.bak +*.compiled +*.o +*.or +*.properties +*.dbg +Article diff --git a/CRules.rc b/CRules.rc new file mode 100644 index 0000000..ae9c4c4 --- /dev/null +++ b/CRules.rc @@ -0,0 +1,6 @@ +Case RCData "Case.txt" +Lang_EnCaps RCData "Lang_EnCaps.txt" +Lang_EnNoCaps RCData "Lang_EnNoCaps.txt" +Lang_RuCaps RCData "Lang_RuCaps.txt" +Lang_RuNoCaps RCData "Lang_RuNoCaps.txt" +Translit RCData "Translit.txt" diff --git a/CRules.res b/CRules.res new file mode 100644 index 0000000..eb1da96 Binary files /dev/null and b/CRules.res differ diff --git a/Case.txt b/Case.txt new file mode 100644 index 0000000..5893bfd --- /dev/null +++ b/Case.txt @@ -0,0 +1,59 @@ +Q=q +W=w +E=e +R=r +T=t +Y=y +U=u +I=i +O=o +P=p +A=a +S=s +D=d +F=f +G=g +H=h +J=j +K=k +L=l +Z=z +X=x +C=c +V=v +B=b +N=n +M=m +É=é +Ö=ö +Ó=ó +Ê=ê +Å=å +Í=í +Ã=ã +Ø=ø +Ù=ù +Ç=ç +Õ=õ +Ú=ú +Ô=ô +Û=û +Â=â +À=à +Ï=ï +Ð=ð +Î=î +Ë=ë +Ä=ä +Æ=æ +Ý=ý +ß=ÿ +×=÷ +Ñ=ñ +Ì=ì +È=è +Ò=ò +Ü=ü +Á=á +Þ=þ +¨=¸ \ No newline at end of file diff --git a/Lang_EnCaps.txt b/Lang_EnCaps.txt new file mode 100644 index 0000000..23bcf0c --- /dev/null +++ b/Lang_EnCaps.txt @@ -0,0 +1,74 @@ +Q=É +W=Ö +E=Ó +R=Ê +T=Å +Y=Í +U=à +I=Ø +O=Ù +P=Ç +[=Õ +]=Ú +A=Ô +S=Û +D= +F=À +G=Ï +H=Ð +J=Î +K=Ë +L=Ä +;=Æ +'=Ý +Z=ß +X=× +C=Ñ +V=Ì +B=È +N=Ò +M=Ü +,=Á +.=Þ +/=. +`=¨ +q=é +w=ö +e=ó +r=ê +t=å +y=í +u=ã +i=ø +o=ù +p=ç +{=õ +}=ú +a=ô +s=û +d=â +f=à +g=ï +h=ð +j=î +k=ë +l=ä +:=æ +"=ý +z=ÿ +x=÷ +c=ñ +v=ì +b=è +n=ò +m=ü +<=á +>=þ +?=, +~=¸ +@=" +#=¹ +$=; +^=: +&=? +|=/ diff --git a/Lang_EnNoCaps.txt b/Lang_EnNoCaps.txt new file mode 100644 index 0000000..a65359e --- /dev/null +++ b/Lang_EnNoCaps.txt @@ -0,0 +1,73 @@ +Q=É +W=Ö +E=Ó +R=Ê +T=Å +Y=Í +U=à +I=Ø +O=Ù +P=Ç +{=Õ +}=Ú +A=Ô +S=Û +D= +F=À +G=Ï +H=Ð +J=Î +K=Ë +L=Ä +:=Æ +"=Ý +Z=ß +X=× +C=Ñ +V=Ì +B=È +N=Ò +M=Ü +<=Á +>=Þ +?=, +~=¨ +@=" +#=¹ +$=; +^=: +&=? +q=é +w=ö +e=ó +r=ê +t=å +y=í +u=ã +i=ø +o=ù +p=ç +[=õ +]=ú +a=ô +s=û +d=â +f=à +g=ï +h=ð +j=î +k=ë +l=ä +;=æ +'=ý +z=ÿ +x=÷ +c=ñ +v=ì +b=è +n=ò +m=ü +,=á +.=þ +/=. +`=¸ \ No newline at end of file diff --git a/Lang_RuCaps.txt b/Lang_RuCaps.txt new file mode 100644 index 0000000..fa05d05 --- /dev/null +++ b/Lang_RuCaps.txt @@ -0,0 +1,74 @@ +é=q +ö=w +ó=e +ê=r +å=t +í=y +ã=u +ø=i +ù=o +ç=p +õ={ +ú=} +/=| +ô=a +û=s +â=d +à=f +ï=g +ð=h +î=j +ë=k +ä=l +æ=: +ý=" +ÿ=z +÷=x +ñ=c +ì=v +è=b +ò=n +ü=m +á=< +þ=> +,=? +¸=~ +"=@ +¹=# +;=$ +:=^ +?=& +É=Q +Ö=W +Ó=E +Ê=R +Å=T +Í=Y +Ã=U +Ø=I +Ù=O +Ç=P +Õ=[ +Ú=] +Ô=A +Û=S +Â=D +À=F +Ï=G +Ð=H +Î=J +Ë=K +Ä=L +Æ=; +Ý=' +ß=Z +×=X +Ñ=C +Ì=V +È=B +Ò=N +Ü=M +Á=, +Þ=. +.=/ +¨=` \ No newline at end of file diff --git a/Lang_RuNoCaps.txt b/Lang_RuNoCaps.txt new file mode 100644 index 0000000..1a4ad5e --- /dev/null +++ b/Lang_RuNoCaps.txt @@ -0,0 +1,74 @@ +É=Q +Ö=W +Ó=E +Ê=R +Å=T +Í=Y +Ã=U +Ø=I +Ù=O +Ç=P +Õ={ +Ú=} +/=| +Ô=A +Û=S +Â=D +À=F +Ï=G +Ð=H +Î=J +Ë=K +Ä=L +Æ=: +Ý=" +ß=Z +×=X +Ñ=C +Ì=V +È=B +Ò=N +Ü=M +Á=< +Þ=> +,=? +¨=~ +"=@ +¹=# +;=$ +:=^ +?=& +é=q +ö=w +ó=e +ê=r +å=t +í=y +ã=u +ø=i +ù=o +ç=p +õ=[ +ú=] +ô=a +û=s +â=d +à=f +ï=g +ð=h +î=j +ë=k +ä=l +æ=; +ý=' +ÿ=z +÷=x +ñ=c +ì=v +è=b +ò=n +ü=m +á=, +þ=. +.=/ +¸=` \ No newline at end of file diff --git a/NiceTypes.pas b/NiceTypes.pas new file mode 100644 index 0000000..a3294a7 --- /dev/null +++ b/NiceTypes.pas @@ -0,0 +1,10 @@ +unit NiceTypes; + +interface + +type + TFormatAction = (faSwitchLang, faSwitchReg, faTranslit, faCodeVertical); + +implementation + +end. diff --git a/TNice.dpr b/TNice.dpr new file mode 100644 index 0000000..bc36794 --- /dev/null +++ b/TNice.dpr @@ -0,0 +1,20 @@ +program TNice; + +{$R 'CRules.res' 'CRules.rc'} + +uses + Forms, + untEditor in 'untEditor.pas' {frmEditor}, + untOptions in 'untOptions.pas' {frmMain}, + NiceTypes in 'NiceTypes.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.ShowMainForm := False; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TfrmMain, frmMain); + Application.CreateForm(TfrmEditor, frmEditor); + Application.Run; +end. diff --git a/TNice.dproj b/TNice.dproj new file mode 100644 index 0000000..7d9838d --- /dev/null +++ b/TNice.dproj @@ -0,0 +1,117 @@ + + + {55D456C6-01AF-40F2-914D-AACE40F77644} + 12.0 + TNice.dpr + Debug + DCC32 + + + true + + + true + Base + true + + + true + Base + true + + + true + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;$(DCC_UnitAlias) + TNice.exe + 00400000 + x86 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + + RC + RC +
CRules.res
+
+ +
frmEditor
+
+ +
frmMain
+
+ + + + + + + + + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + +
+ + + Delphi.Personality.12 + + + + + TNice.dpr + + + False + True + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + 12 + +
diff --git a/TNice.res b/TNice.res new file mode 100644 index 0000000..608c7c5 Binary files /dev/null and b/TNice.res differ diff --git a/Translit.txt b/Translit.txt new file mode 100644 index 0000000..2d16b35 --- /dev/null +++ b/Translit.txt @@ -0,0 +1,62 @@ +À=A +Á=B +Â=V +Ã=G +Ä=D +Å=E +¨=E +Æ=J +Ç=Z +È=I +É=I +Ê=K +Ë=L +Ì=M +Í=N +Î=O +Ï=P +Ð=R +Ñ=S +Ò=T +Ó=U +Ô=F +Õ=H +Ö=C +×=Ch +Ø=Sh +Ù=Sch +Û=Y +Ý=E +Þ=Yu +ß=Ya +à=a +á=b +â=v +ã=g +ä=d +å=e +¸=e +æ=j +ç=z +è=i +é=i +ê=k +ë=l +ì=m +í=n +î=o +ï=p +ð=r +ñ=s +ò=t +ó=u +ô=f +õ=h +ö=c +÷=ch +ø=sh +ù=sch +û=y +ý=e +þ=yu +ÿ=ya \ No newline at end of file diff --git a/agt_action_fail.ico b/agt_action_fail.ico new file mode 100644 index 0000000..3ea5c5d Binary files /dev/null and b/agt_action_fail.ico differ diff --git a/agt_action_success.ico b/agt_action_success.ico new file mode 100644 index 0000000..e207e20 Binary files /dev/null and b/agt_action_success.ico differ diff --git a/text_x_chdr.ico b/text_x_chdr.ico new file mode 100644 index 0000000..1a74ba1 Binary files /dev/null and b/text_x_chdr.ico differ diff --git a/untEditor.dfm b/untEditor.dfm new file mode 100644 index 0000000..8b3cca6 --- /dev/null +++ b/untEditor.dfm @@ -0,0 +1,75 @@ +object frmEditor: TfrmEditor + Left = 0 + Top = 0 + BorderIcons = [] + BorderStyle = bsNone + Caption = 'frmEditor' + ClientHeight = 256 + ClientWidth = 888 + Color = clBtnFace + DoubleBuffered = True + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + FormStyle = fsStayOnTop + OldCreateOrder = False + OnCreate = FormCreate + OnDestroy = FormDestroy + OnDeactivate = FormDeactivate + OnShow = FormShow + DesignSize = ( + 888 + 256) + PixelsPerInch = 96 + TextHeight = 13 + object mmCode: TMemo + Left = 0 + Top = 0 + Width = 742 + Height = 256 + Anchors = [akLeft, akTop, akRight, akBottom] + Font.Charset = RUSSIAN_CHARSET + Font.Color = clWindowText + Font.Height = -15 + Font.Name = 'Courier New' + Font.Style = [] + Lines.Strings = ( + 'mmCode') + ParentFont = False + ReadOnly = True + ScrollBars = ssBoth + TabOrder = 0 + WordWrap = False + end + object mmSeparators: TMemo + Left = 741 + Top = 0 + Width = 147 + Height = 256 + Anchors = [akTop, akRight, akBottom] + Font.Charset = RUSSIAN_CHARSET + Font.Color = clWindowText + Font.Height = -15 + Font.Name = 'Courier New' + Font.Style = [fsUnderline] + ParentFont = False + ScrollBars = ssBoth + TabOrder = 1 + WordWrap = False + OnChange = mmSeparatorsChange + OnKeyDown = mmSeparatorsKeyDown + end + object ApplicationEvents1: TApplicationEvents + OnDeactivate = ApplicationEvents1Deactivate + Left = 432 + Top = 112 + end + object Timer1: TTimer + Interval = 100 + OnTimer = Timer1Timer + Left = 184 + Top = 72 + end +end diff --git a/untEditor.pas b/untEditor.pas new file mode 100644 index 0000000..6d66753 --- /dev/null +++ b/untEditor.pas @@ -0,0 +1,250 @@ +unit untEditor; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, AppEvnts, ExtCtrls; + +type + TfrmEditor = class(TForm) + mmCode: TMemo; + mmSeparators: TMemo; + ApplicationEvents1: TApplicationEvents; + Timer1: TTimer; + procedure FormCreate(Sender: TObject); + procedure mmSeparatorsChange(Sender: TObject); + procedure FormDeactivate(Sender: TObject); + procedure ApplicationEvents1Deactivate(Sender: TObject); + procedure Timer1Timer(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure mmSeparatorsKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FSrc: TStringList; + FSourceStr: string; + FSrcWnd: HWND; + FPrevSeparators: TStringList; + procedure DoFormat(const Src, Sep: TStrings; const Dest: TStrings); + protected + procedure CreateParams(var Params: TCreateParams); override; + procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING; + public + procedure SetOptions(const FontName: string; FontSize: Integer; FontColor: TColor; BackColor: TColor); + + property SrcWnd: HWND read FSrcWnd write FSrcWnd; + property SourceStr: string read FSourceStr write FSourceStr; + function ForamtedStr: string; + end; + +var + frmEditor: TfrmEditor; + +implementation + +uses Math; + +{$R *.dfm} + +{ TfrmEditor } + +procedure TfrmEditor.ApplicationEvents1Deactivate(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrmEditor.CreateParams(var Params: TCreateParams); +begin + inherited; + Params.Style := Params.Style or WS_THICKFRAME; +end; + +procedure TfrmEditor.DoFormat(const Src, Sep, Dest: TStrings); + function GetSpaces(const n: Integer): string; + var i: Integer; + begin + if n = 0 then + begin + Result := ''; + Exit; + end; + SetLength(Result, n); + for i := 1 to n do + Result[i] := ' '; + end; + function SplitStr(const src, separator: string; out before, after: string): Boolean; + var n: Integer; + begin + n := Pos(separator, src); + if n = 0 then + begin + Result := False; + Exit; + end; + before := Copy(src, 1, n - 1); + n := n + Length(separator); + after := Copy(src, n, Length(src) - n + 1); + Result := True; + end; +var i, j, n, maxn: Integer; + before, after: string; + SrcCopy: TStringList; +begin + Dest.Clear; + SrcCopy := TStringList.Create; + try + SrcCopy.AddStrings(Src); + for i := 0 to SrcCopy.Count - 1 do Dest.Add(''); + + for j := 0 to Sep.Count - 1 do + begin + maxn := 0; + for i := 0 to SrcCopy.Count - 1 do + begin + n := Pos(Sep.Strings[j], SrcCopy.Strings[i]); + maxn := Max(maxn, n); + end; + + if maxn > 0 then + begin + Dec(maxn); + for i := 0 to SrcCopy.Count - 1 do + begin + if SplitStr(SrcCopy.Strings[i], Sep.Strings[j], before, after) then + begin + SrcCopy.Strings[i] := after; + before := before + GetSpaces(maxn - Length(before)) + Sep.Strings[j]; + Dest.Strings[i] := Dest.Strings[i] + before; + end + else + begin + Dest.Strings[i] := Dest.Strings[i] + SrcCopy.Strings[i]; + SrcCopy.Strings[i] := ''; + end; + end; + end; + + //debug output code +{ + AllocConsole; + WriteLn('Sep: ', Sep.Strings[j]); + WriteLn('Src'); + for i := 0 to SrcCopy.Count - 1 do + Writeln(SrcCopy.Strings[i], '#'); + WriteLn('Dest'); + for i := 0 to Dest.Count - 1 do + Writeln(Dest.Strings[i], '#'); + WriteLn('--------------'); +} + end; + for i := 0 to SrcCopy.Count - 1 do + Dest.Strings[i] := Dest.Strings[i] + SrcCopy.Strings[i]; + finally + FreeAndNil(SrcCopy); + end; +end; + +function TfrmEditor.ForamtedStr: string; +var HasBreak: Boolean; +begin + HasBreak := False; + if Length(FSourceStr)>0 then + begin + HasBreak := (FSourceStr[Length(FSourceStr)] = #13); + if not HasBreak and (Length(FSourceStr)>1) then + HasBreak := (FSourceStr[Length(FSourceStr)-1] = #13) or (FSourceStr[Length(FSourceStr)] = #10); + end; + Result := mmCode.Text; + if not HasBreak then + if Length(Result) > 1 then + if (Result[Length(Result)-1] = #13) and (Result[Length(Result)] = #10) then + Delete(Result, Length(Result) - 1, 2); +end; + +procedure TfrmEditor.FormCreate(Sender: TObject); +begin + FPrevSeparators := TStringList.Create; + FSrc := TStringList.Create; +end; + +procedure TfrmEditor.FormDeactivate(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrmEditor.FormDestroy(Sender: TObject); +begin + FreeAndNil(FPrevSeparators); + FreeAndNil(FSrc); +end; + +procedure TfrmEditor.FormShow(Sender: TObject); +begin + FSrc.Text := FSourceStr; + mmSeparators.Lines.BeginUpdate; + try + mmSeparators.Lines.Clear; + mmSeparators.Lines.AddStrings(FPrevSeparators); + finally + mmSeparators.Lines.EndUpdate; + end; + mmSeparators.SetFocus; + mmSeparators.SelectAll; + DoFormat(FSrc, mmSeparators.Lines, mmCode.Lines); + Left := -1; +end; + +procedure TfrmEditor.mmSeparatorsChange(Sender: TObject); +begin + mmCode.Lines.BeginUpdate; + try + DoFormat(FSrc, mmSeparators.Lines, mmCode.Lines); + finally + mmCode.Lines.EndUpdate; + end; +end; + +procedure TfrmEditor.mmSeparatorsKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if (Key = VK_RETURN) and (ssCtrl in Shift) then + begin + FPrevSeparators.Clear; + FPrevSeparators.AddStrings(mmSeparators.Lines); + ModalResult := mrOk; + end; + if (Key = VK_ESCAPE) then + ModalResult := mrCancel; +end; + +procedure TfrmEditor.SetOptions(const FontName: string; FontSize: Integer; + FontColor, BackColor: TColor); +begin + mmCode.Font.Name := FontName; + mmCode.Font.Size := FontSize; + mmCode.Font.Color := FontColor; + mmCode.Color := BackColor; + + mmSeparators.Font.Name := FontName; + mmSeparators.Font.Size := FontSize; + mmSeparators.Font.Color := FontColor; + mmSeparators.Color := BackColor; +end; + +procedure TfrmEditor.Timer1Timer(Sender: TObject); +begin + if Visible then + SetForegroundWindow(Handle); +end; + +procedure TfrmEditor.WMWindowPosChanging(var Message: TWMWindowPosChanging); +var SrcRct: TRect; +begin + inherited; + GetWindowRect(FSrcWnd, SrcRct); + Message.WindowPos.x := SrcRct.Right - Message.WindowPos.cx; + Message.WindowPos.y := SrcRct.Bottom - Message.WindowPos.cy; +end; + +end. diff --git a/untOptions.dfm b/untOptions.dfm new file mode 100644 index 0000000..8d97ffd --- /dev/null +++ b/untOptions.dfm @@ -0,0 +1,539 @@ +object frmMain: TfrmMain + Left = 0 + Top = 0 + BorderIcons = [biSystemMenu] + BorderStyle = bsSingle + Caption = 'TNice ;)' + ClientHeight = 207 + ClientWidth = 662 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + KeyPreview = True + OldCreateOrder = False + Position = poScreenCenter + OnCloseQuery = FormCloseQuery + OnCreate = FormCreate + OnDestroy = FormDestroy + PixelsPerInch = 96 + TextHeight = 13 + object GroupBox1: TGroupBox + Left = 8 + Top = 8 + Width = 273 + Height = 161 + Caption = 'Hotkeys' + TabOrder = 0 + object Label1: TLabel + Left = 16 + Top = 24 + Width = 82 + Height = 13 + Caption = 'Switch language:' + end + object Label2: TLabel + Left = 16 + Top = 59 + Width = 60 + Height = 13 + Caption = 'Switch case:' + end + object Label3: TLabel + Left = 16 + Top = 92 + Width = 52 + Height = 13 + Caption = 'To translit:' + end + object Label4: TLabel + Left = 16 + Top = 127 + Width = 64 + Height = 13 + Caption = 'Code aligner:' + end + object imgSwitchLang: TImage + Left = 231 + Top = 18 + Width = 24 + Height = 24 + end + object imgSwitchReg: TImage + Left = 231 + Top = 53 + Width = 24 + Height = 24 + end + object imgTranslit: TImage + Left = 231 + Top = 86 + Width = 24 + Height = 24 + end + object imgCodeAligner: TImage + Left = 231 + Top = 121 + Width = 24 + Height = 24 + end + object hkSwitchLang: THotKey + Left = 104 + Top = 21 + Width = 121 + Height = 19 + HotKey = 8257 + InvalidKeys = [hcNone, hcAlt, hcShiftAlt, hcCtrlAlt] + Modifiers = [hkShift] + TabOrder = 0 + OnChange = hkSwitchLangChange + end + object hkSwitchReg: THotKey + Left = 104 + Top = 56 + Width = 121 + Height = 19 + HotKey = 32833 + InvalidKeys = [hcNone, hcAlt, hcShiftAlt, hcCtrlAlt] + TabOrder = 1 + OnChange = hkSwitchRegChange + end + object hkCodeAligner: THotKey + Left = 104 + Top = 124 + Width = 121 + Height = 19 + HotKey = 32833 + InvalidKeys = [hcNone, hcAlt, hcShiftAlt, hcCtrlAlt] + TabOrder = 2 + OnChange = hkCodeAlignerChange + end + object hkTranslit: THotKey + Left = 104 + Top = 89 + Width = 121 + Height = 19 + HotKey = 32833 + InvalidKeys = [hcNone, hcAlt, hcShiftAlt, hcCtrlAlt] + TabOrder = 3 + OnChange = hkTranslitChange + end + end + object GroupBox2: TGroupBox + Left = 287 + Top = 7 + Width = 370 + Height = 161 + Caption = 'Code aligner' + TabOrder = 1 + object Label5: TLabel + Left = 11 + Top = 80 + Width = 52 + Height = 13 + Caption = 'Font color:' + end + object Label6: TLabel + Left = 163 + Top = 80 + Width = 86 + Height = 13 + Caption = 'Background color:' + end + object imgFontColor: TImage + Left = 11 + Top = 99 + Width = 102 + Height = 29 + Stretch = True + OnClick = imgFontColorClick + end + object imgBackColor: TImage + Left = 163 + Top = 99 + Width = 102 + Height = 29 + Stretch = True + OnClick = imgBackColorClick + end + object cbFont: TComboBox + Left = 11 + Top = 15 + Width = 263 + Height = 22 + Style = csOwnerDrawFixed + TabOrder = 0 + OnDrawItem = cbFontDrawItem + end + end + object Button1: TButton + Left = 582 + Top = 174 + Width = 75 + Height = 25 + Caption = 'Ok' + TabOrder = 2 + OnClick = Button1Click + end + object Button3: TButton + Left = 8 + Top = 176 + Width = 41 + Height = 25 + Caption = 'Exit' + TabOrder = 3 + OnClick = Button3Click + end + object edFontSize: TSpinEdit + Left = 567 + Top = 22 + Width = 81 + Height = 22 + AutoSize = False + MaxValue = 30 + MinValue = 8 + TabOrder = 4 + Value = 11 + OnChange = edFontSizeChange + end + object Button2: TButton + Left = 64 + Top = 176 + Width = 75 + Height = 25 + Caption = 'Default' + TabOrder = 5 + OnClick = Button2Click + end + object imgHKList: TImageList + Height = 24 + Width = 24 + Left = 208 + Top = 160 + Bitmap = { + 494C010102000800300018001800FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000600000001800000001002000000000000024 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FCFCFC03C9C9CE369090A66F7A7A + 98867676958A8989A076BCBCC243EFEFF0100000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000F7F7F80887879F780F116FF515169AFF2629BEFF3135 + CEFF3236CEFF272AC0FF14179DFF07076CFF6E6E8A92DDDDE122000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000C3C3D23C141569F01317B3FF282EEAFF3F47FBFF515AFFFF5C64 + FFFF5D66FFFF545DFFFF424AFCFF2A31EEFF1317BAFF050769FF9F9FA9600000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000C4F2C84B4A964CC8EDFFEF1F0000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000AAAAB7550A0D7FFF1721DFFF1922F4FF1420E2FF242DE5FF343EF2FF3E45 + F7FF3F47F9FF3D44F5FF2F38EBFF1D26E5FF1620EFFF151FE0FF090C87FF8080 + 927F000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000C2EEC548329536ED62D168FF419244DDF4FF + F51B000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000CBCB + D934090D7DFF111DE6FF0912E7FF0810C4FF1821C0FF2026BAFF181FB2FF181D + B8FF1E20BBFF2427BFFF2C30CAFF252CCAFF0C14C7FF060FDEFF0E18E4FF080B + 87FFA0A0AB5F0000000000000000000000000000000000000000000000000000 + 00000000000000000000BDE8C14829932EEC70EE7AFF90FF9CFF5FE168FF4091 + 42DDEFFEF01C0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000001416 + 69F11118D2FF030ADAFF0007B4FF060FBBFF3135D2FF242199F6C4C4DC3BDDDD + ED22D9D9EB26B7B7D8487171AE94212399FF292FBBFF0A11BDFF0006CFFF0C14 + D2FF050869FFDEDEE12100000000000000000000000000000000000000000000 + 000000000000BAE5BE46278D2CEA56E762FF63FF72FF63FE71FF73FF82FF4DDF + 57FF368F3ADCEBFCED1B00000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000009A9BBA650E15 + A2FF070ED3FF0002A0FF0003ADFF0109BAFF1017C7FF0809C9FFA0A0D25F0000 + 0000000000000000000000000000CCCCDE33202280F3242AA7FF070AA8FF0309 + C5FF0B11AAFF6162839E00000000000000000000000000000000000000000000 + 0000B8DFBB47218828EC4ADC56FF4EF45EFF62F370FF6FF77CFF57F866FF61FF + 70FF44DD4EFF308C34DDE9FAEB1B000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000001B1F73E90F16 + C7FF00019AFF0E128CFF1D23A8FF030AAFFF0004B1FF010AC8FF0206C0FF8A8A + AD7500000000000000000000000000000000DFDFE9201B1F75FF172193FF0003 + 95FF090FBCFF05096BFFEBEBEC1400000000000000000000000000000000B7D8 + BA481F8628EC39D047FF42E251FF6CE877FF87EE90FF84EF8EFF6CEF79FF4DEE + 5CFF57F767FF41D94BFF2D8531DDE7F8E91B0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000E7E7EF180A1081FF080D + B1FF000171FF101587FF2C3182F0030B82FF0006A6FF0009AAFF020ABAFF0409 + ADFF8B8BAA74000000000000000000000000000000008687AF7A161F72FF070A + 75FF02069EFF080E89FFB0B0BB4F000000000000000000000000BCD6BE492E82 + 35ED27BF36FF44D552FF80E289FF8EE696FF8AE893FFC7F6CCFF7EE888FF66E7 + 72FF43E452FF4CED5CFF3CCA46FF287B2DDDE4F6E61C00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000AFAFCD500F1598FF0206 + 88FF010560FF030775FFDCDCE7249598C06C00088AFF0008A1FF0007A6FF040B + B0FF080E9AFF8687A179000000000000000000000000D9D9E82611175DFF0B11 + 5CFF000375FF080E8CFF767795890000000000000000C4DEC747549559EB28B4 + 36FF55CE61FF94DF9BFF92E09AFF8FE297FFDDF5DFFF429946FFC4F3C8FF7AE2 + 84FF5DDF6AFF39DA48FF42E552FF33B63DFF267329DCE4F3E51B000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000008C8DB97311169CFF0002 + 66FF03085BFF111379F200000000000000007B7FBF84050CA3FF020AB5FF0008 + BBFF060EBEFF0B138AFF878899780000000000000000000000001B1F65EE0B11 + 65FF000373FF090E96FF595A87A600000000DDECDD224E9252EC51BC5BFF75CF + 7EFFA5DFABFF97DC9DFF97DD9DFFDFF5E1FF299231E5C8ECCB43479F4DFCBCEE + C1FF77DC80FF56D763FF2ECF3DFF37DB46FF2BA936FF236A26DDE4F0E51B0000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000008889B9771016A2FF0002 + 7FFF060B83FF181B86EEFDFDFD0200000000000000007D7FD1830910BBFF030B + BEFF0007C1FF0811C0FF0F1781FF8789937800000000000000001E2169E8080E + 79FF01048FFF0A0EAFFF56588BA900000000F1F7F10E66A66ABFA5D8ABFFBADF + BEFFA2D8A7FFA3DAA8FFE1F4E3FF2CA136E3D4F0D72C00000000D0EFD3322993 + 30FDBCEBC1FF71D67BFF4FCE5BFF22C331FF2BCF3AFF249C2EFF236226DDE4EC + E41B000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000A4A4CE5B1116B6FF0003 + 9EFF090D94FF0F128BFFDCDCE523000000000000000000000000797BDF870E14 + C9FF050EC3FF0107C5FF0B12C4FF131D7DFF989AAB67F4F4F60B04085AFF030A + 87FF00039DFF080EB0FF73749D8C0000000000000000F2F9F30D53A85ABCBAE2 + BFFFC2DEC7FFE4F3E5FF2D9C34E1D2EED42D000000000000000000000000CEEE + D132268E2EFDBAE8BEFF6CCF75FF47C453FF16B725FF1EC22EFF1D9829FF235E + 26DDE3EAE31C0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000E0E0EF1F1219ABFF1013 + B6FF13179DFF1D20ACFF8F8FB670000000000000000000000000000000007C7C + F085171EDAFF121DC9FF0B12CAFF1D23C9FF1E2580FF3D3F63CD0C136DFF0B11 + A1FF0F14B6FF0E15ADFFADADC352000000000000000000000000F2F9F20D44A7 + 4CC0C8E8CBFF37A13FE4D0EDD12F000000000000000000000000000000000000 + 0000CBECCE3422892AFDB7E4BCFF67C870FF3EBB49FF09AA18FF10B620FF1691 + 22FF255F29DBE5ECE51A00000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000010159FFF3236 + D8FF282BB0FF3034C2FF0F1185FDEBEBED140000000000000000000000000000 + 00007F7EF6842A2DE7FF3036D6FF2228D1FF343BCFFF5056A5FF3238A7FF2126 + B7FF3035D4FF12179BFFEBEBF01400000000000000000000000000000000EFF9 + F01068B26C9ACEEDD13200000000000000000000000000000000000000000000 + 000000000000CCEACD33218329FDB8DFBCFF65BD6FFF38AF44FF009B0DFF04A6 + 12FF148E1FFF386C3ADCE5EDE61B000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000008787C87B3C44 + D9FF4649DBFF474ACBFF363AC7FF2E2F81D3EBEBEE1400000000000000000000 + 0000000000009190FE753B3EE6FF464CE4FF3B44DCFF4B50DFFF4347D2FF4448 + DAFF3B43DEFF585AA5AB00000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000CCE9CE3323822BFDBADABDFF68B16FFF399F43FF0085 + 0AFF008D08FF3A9B44FF3E6E40D4EFF3EF100000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000FDFDFE022025 + B2FF6369F7FF5C60E6FF6064E6FF3E45C9FF121377F69B9BBD64E5E5E91A0000 + 000000000000F2F2F80D3233A9DA3D3FB7FF5E63EBFF4E53E5FF595FE7FF636A + F9FF2328B0FFDADAE72500000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000CDEBCE3225822CFCBBD7BDFF6BAA71FF3B92 + 44FF04730AFF87BB8DFF346E38D1EFF3EF100000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000B6B7 + DF493C45D3FF8288FCFF787DF7FF767DF6FF5E62E0FF2F33A1FF101372FF1E22 + 6BE41C2156E50B0F4EFE30348DFF4D50C7FF7479F8FF757AF7FF8289FDFF4248 + D6FF8E8FC8720000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000CBEACC3426832DFDBCD6BFFF6FA8 + 74FFB1D2B4FF2D7833D3E5EDE51A000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00008C8DD075484EDFFF949AFEFF989DFDFF9195FCFF898EFAFF777CEDFF6B70 + DCFF696FDAFF7178E6FF8388F6FF8A8FFAFF9A9EFCFF9A9FFFFF4C52E2FF6768 + BC9C000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000CCEBCD3329822FFDC6DE + C8FF5A9E5FD1E5EFE51A00000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000A6A6DC5A3136D0FF898EFCFFB2B7FFFFBABDFFFFB7BBFEFFB4B9 + FEFFB5B9FEFFB8BBFFFFBBBFFFFFB7BBFFFF8F95FCFF363AD0FF8A8BCE770000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000CBE9CD344D9C + 53C1E5F2E61B0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000E9E9F6166465CDA3383DD9FF464AD3FF8C91F5FFA9AE + FEFFA9AEFEFF9DA2FDFF8B90F5FF3C44DCFF4F51C5BAD5D5EE2A000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000D7D7EC28AAAAE2576C6CD5993C3E + C0DC3B3DC0DD4748C1CF6364C6B1CECEE931EAEAF51500000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000060000000180000000100010000000000200100000000000000000000 + 000000000000000000000000FFFFFF00FFFFFFFFFFFF000000000000FF00FFFF + FFFF000000000000FC003FFFFFFF000000000000F8001FFF1FFF000000000000 + F0000FFE0FFF000000000000E00007FC07FF000000000000E00003F803FF0000 + 00000000C01E03F001FF000000000000C00F01E000FF000000000000800781C0 + 007F00000000000080038180003F0000000000008301C100001F000000000000 + 8180C100400F00000000000081C00180E00700000000000081E001C1F0030000 + 00000000C0F001E3F801000000000000C07803FFFC00000000000000C01803FF + FE00000000000000E00007FFFF01000000000000F0000FFFFF83000000000000 + F8001FFFFFC7000000000000FC003FFFFFFF000000000000FF007FFFFFFF0000 + 00000000FFFFFFFFFFFF00000000000000000000000000000000000000000000 + 000000000000} + end + object TrayIcon1: TTrayIcon + PopupMenu = PopupMenu1 + Visible = True + OnClick = TrayIcon1Click + Left = 280 + Top = 160 + end + object PopupMenu1: TPopupMenu + Left = 344 + Top = 160 + object Ext1: TMenuItem + Caption = 'Exit' + OnClick = Ext1Click + end + end + object ColorDialog1: TColorDialog + Left = 576 + Top = 88 + end +end diff --git a/untOptions.pas b/untOptions.pas new file mode 100644 index 0000000..c114e35 --- /dev/null +++ b/untOptions.pas @@ -0,0 +1,783 @@ +unit untOptions; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ComCtrls, StdCtrls, ExtCtrls, NiceTypes, ImgList, Generics.Collections, + Spin, Menus, Registry; + +const + LAYOUT_RU = $419; + LAYOUT_EN = $409; + + LAYOUT_RU_STR = '00000419'; + LAYOUT_EN_STR = '00000409'; + + REG_Key = 'Software\TNice'; + REG_Value_FontName = 'FontName'; + REG_Value_FontSize = 'FontSize'; + REG_Value_FontColor = 'FontColor'; + REG_Value_BackColor = 'BackColor'; + REG_Value_EditorW = 'CodeEditorWidth'; + REG_Value_EditorH = 'CodeEditorHeight'; + REG_Value_Hotkey_SLang = 'HK_SwitchLang'; + REG_Value_Modifier_SLang = 'Mod_SwitchLang'; + REG_Value_Hotkey_SCase = 'HK_SwitchCase'; + REG_Value_Modifier_SCase = 'Mod_SwitchCase'; + REG_Value_Hotkey_Trans = 'HK_Trans'; + REG_Value_Modifier_Trans = 'Mod_Trans'; + REG_Value_Hotkey_CodeVAlign = 'HK_CodeVAlign'; + REG_Value_Modifier_CodeVAlign = 'Mod_CodeVAlign'; + + +type + TCurrentLang = (clEn, clRu); + TCapsState = (csOff, csOn); + + TfrmMain = class(TForm) + GroupBox1: TGroupBox; + hkSwitchLang: THotKey; + Label1: TLabel; + Label2: TLabel; + hkSwitchReg: THotKey; + Label3: TLabel; + hkCodeAligner: THotKey; + Label4: TLabel; + hkTranslit: THotKey; + GroupBox2: TGroupBox; + Button1: TButton; + Button3: TButton; + imgSwitchLang: TImage; + imgSwitchReg: TImage; + imgTranslit: TImage; + imgCodeAligner: TImage; + imgHKList: TImageList; + TrayIcon1: TTrayIcon; + edFontSize: TSpinEdit; + PopupMenu1: TPopupMenu; + Ext1: TMenuItem; + cbFont: TComboBox; + Label5: TLabel; + Label6: TLabel; + imgFontColor: TImage; + imgBackColor: TImage; + ColorDialog1: TColorDialog; + Button2: TButton; + procedure FormCreate(Sender: TObject); + procedure hkSwitchLangChange(Sender: TObject); + procedure hkSwitchRegChange(Sender: TObject); + procedure hkTranslitChange(Sender: TObject); + procedure hkCodeAlignerChange(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure Button1Click(Sender: TObject); + procedure Button3Click(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure TrayIcon1Click(Sender: TObject); + procedure Ext1Click(Sender: TObject); + procedure cbFontDrawItem(Control: TWinControl; Index: Integer; + Rect: TRect; State: TOwnerDrawState); + procedure edFontSizeChange(Sender: TObject); + procedure imgFontColorClick(Sender: TObject); + procedure imgBackColorClick(Sender: TObject); + procedure Button2Click(Sender: TObject); + private + FIsExit: Boolean; + + FLang : array [TCurrentLang, TCapsState] of TDictionary; + FCaps : TDictionary; + FTrans : TDictionary; + + FNewEditorW : Integer; + FNewEditorH : Integer; + + FRegistredHotkey: array [TFormatAction] of Boolean; + procedure RegHK(const Action: TFormatAction; const Key: TShortCut; const Modifiers: THKModifiers); + + procedure SendCtrlKey(const VKey: Word); + + procedure DoSwitchLayout(h: HWND); + function CanSwitchLayoutNow(h: HWND; out ActiveLayout: TCurrentLang): Boolean; + + function SwitchSymbols(const Dic: TDictionary; const Src: string): string; + function ReplaceSymbols(const Dic: TDictionary; const Src: string): string; + function DoVerticalFormat(const SrcWnd: HWND; const Src: string; out FormatedStr: string): boolean; + + procedure ProcessBuffer(const action: TFormatAction); + procedure WMHotkey(var msg: TWMHotKey); message WM_HOTKEY; + + procedure SetColor(img: TImage; color: TColor); + function GetColor(img: TImage): TColor; + public + procedure SetDefaultSettings; + procedure SaveSettings; + procedure LoadSettings; + end; + +var + frmMain: TfrmMain; + +implementation + +uses + Clipbrd, untEditor, Math; + +const HK_Base = 17; +const HK_ID: array [TFormatAction] of Cardinal = (HK_Base + 1, //faSwitchLang + HK_Base + 2, //faSwitchReg + HK_Base + 3, //faTranslit + HK_Base + 4);//faCodeVertical +const HK_IconIndex: array [Boolean] of Integer = (0, 1); + +function EnumFontProc(var LogFont: TEnumLogFontEx; var Metrics: TEnumTextMetricW; FontType: Cardinal; Strings: TStrings): Integer; stdcall; +begin + if (LogFont.elfLogFont.lfPitchAndFamily and FF_MODERN = FF_MODERN) then + Strings.Add(LogFont.elfFullName); + Result := 1; +end; + +procedure GetFontList(str: TStrings); +var sl: TStringList; + DC: HDC; + lf: TLogFont; +begin + sl := nil; + if str = nil then Exit; + str.Clear; + DC := GetDC(0); + try + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupIgnore; + + FillChar(lf, SizeOf(lf), 0); + lf.lfPitchAndFamily := DEFAULT_PITCH or FF_MODERN; + EnumFontFamiliesEx(DC, lf, @EnumFontProc, Integer(sl), 0); + + str.Assign(sl); + finally + FreeAndNil(sl); + ReleaseDC(0, DC); + end; +end; + +{$R *.dfm} + +procedure TfrmMain.Button1Click(Sender: TObject); +begin + Hide; +end; + +procedure TfrmMain.Button2Click(Sender: TObject); +begin + SetDefaultSettings; +end; + +procedure TfrmMain.Button3Click(Sender: TObject); +begin + FIsExit := True; + Close; +end; + +function TfrmMain.CanSwitchLayoutNow(h: HWND; out ActiveLayout: TCurrentLang): Boolean; +var layouts: array of HKL; +// layoutname: array [0..KL_NAMELENGTH-1] of WideChar; + i:integer; + hasEn, hasRu: boolean; + currentLayout: HKL; +begin +// SetLength(layouts, 1); + SetLength(layouts, GetKeyboardLayoutList(0, layouts[0])); + GetKeyboardLayoutList(length(layouts),layouts[0]); + + hasEn := False; + hasRu := False; + for i := 0 to Length(layouts) - 1 do + begin + hasEn := hasEn or (Word(layouts[i]) = LAYOUT_EN); + hasRu := hasRu or (Word(layouts[i]) = LAYOUT_RU); + end; + + currentLayout := GetKeyboardLayout(GetWindowThreadProcessId(h)); + if not (hasEn and hasRu) then Exit(False); + if (Word(currentLayout) = LAYOUT_EN) then + begin + ActiveLayout := clEn; + Exit(True); + end; + if (Word(currentLayout) = LAYOUT_RU) then + begin + ActiveLayout := clRu; + Exit(True); + end; + Result := False; +end; + +procedure TfrmMain.cbFontDrawItem(Control: TWinControl; Index: Integer; + Rect: TRect; State: TOwnerDrawState); +var s: string; +begin + if Control = cbFont then + begin + cbFont.Canvas.Brush.Style := bsSolid; + if odSelected in State then + cbFont.Canvas.Brush.Color := clHighlight + else + cbFont.Canvas.Brush.Color := clWindow; + cbFont.Canvas.FillRect(Rect); + + s := cbFont.Items[Index]; + cbFont.Canvas.Font.Name := s; + cbFont.Canvas.Font.Size := edFontSize.Value; + cbFont.Canvas.TextRect(Rect, s, [tfSingleLine, tfVerticalCenter]); + end; +end; + +procedure TfrmMain.DoSwitchLayout(h: HWND); +const KLF_SETFORPROCESS = $00000100; +var currentLayout: HKL; +begin + currentLayout := GetKeyboardLayout(GetWindowThreadProcessId(h)); + if Word(currentLayout) = LAYOUT_EN then + begin + SendMessage(h, WM_INPUTLANGCHANGEREQUEST, 2, + LoadKeyboardLayout('00000419', KLF_ACTIVATE or KLF_SETFORPROCESS)); + end + else + begin + SendMessage(h, WM_INPUTLANGCHANGEREQUEST, 2, + LoadKeyboardLayout('00000409', KLF_ACTIVATE or KLF_SETFORPROCESS)); + end; +end; + +function TfrmMain.DoVerticalFormat(const SrcWnd: HWND; const Src: string; out FormatedStr: string): boolean; +begin + if frmEditor.Visible then + begin + frmEditor.ModalResult := mrCancel; + Result := False; + Exit; + end; + + frmEditor.SetOptions(cbFont.Text, edFontSize.Value, GetColor(imgFontColor), GetColor(imgBackColor)); + frmEditor.SrcWnd := SrcWnd; + frmEditor.SourceStr := Src; + frmEditor.Width := FNewEditorW; + frmEditor.Height := FNewEditorH; + if frmEditor.ShowModal = ID_OK then + begin + FormatedStr := frmEditor.ForamtedStr; + Result := True; + end + else + begin + Result := False; + end; + FNewEditorW := frmEditor.Width; + FNewEditorH := frmEditor.Height; +end; + +procedure TfrmMain.edFontSizeChange(Sender: TObject); +begin + cbFont.ItemHeight := Max(12, (edFontSize.Value + 6)); + edFontSize.Font.Size := 8; + edFontSize.Height := cbFont.Height; + edFontSize.Font.Size := Trunc((edFontSize.Value - 8) * 0.5) + 8; +end; + +procedure TfrmMain.Ext1Click(Sender: TObject); +begin + FIsExit := True; + Close; +end; + +procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + CanClose := FIsExit; + if not FIsExit then Hide; +end; + +procedure TfrmMain.FormCreate(Sender: TObject); + procedure LoadResToStringList(const sl: TStringList; const resname: string); + var rs: TResourceStream; + begin + rs := TResourceStream.Create(HInstance, resname, RT_RCDATA); + try + sl.LoadFromStream(rs); + finally + FreeAndNil(rs); + end; + end; + procedure LoadResToDic(const dic: TDictionary; const resname: string); overload; + var sl: TStringList; + i: Integer; + begin + sl := TStringList.Create; + try + LoadResToStringList(sl, resname); + for i := 0 to sl.Count - 1 do + dic.Add(sl.Names[i][1], sl.ValueFromIndex[i][1]); + finally + FreeAndNil(sl); + end; + end; + procedure LoadResToDic(const dic: TDictionary; const resname: string); overload; + var sl: TStringList; + i: Integer; + begin + sl := TStringList.Create; + try + LoadResToStringList(sl, resname); + for i := 0 to sl.Count - 1 do + dic.Add(sl.Names[i][1], sl.ValueFromIndex[i]); + finally + FreeAndNil(sl); + end; + end; + procedure AddReverse(const Dic: TDictionary); + var pair: TPair; + lst: TList>; + i: Integer; + begin + lst := TList>.Create; + try + for pair in Dic do lst.Add(Pair); + for i := 0 to lst.Count - 1 do + Dic.AddOrSetValue(lst.Items[i].Value, lst.Items[i].Key); + finally + FreeAndNil(lst); + end; + end; +begin + FLang[clEn, csOff] := TDictionary.Create; + LoadResToDic(FLang[clEn, csOff], 'Lang_EnNoCaps'); + FLang[clEn, csOn] := TDictionary.Create; + LoadResToDic(FLang[clEn, csOn], 'Lang_EnCaps'); + FLang[clRu, csOff] := TDictionary.Create; + LoadResToDic(FLang[clRu, csOff], 'Lang_RuNoCaps'); + FLang[clRu, csOn] := TDictionary.Create; + LoadResToDic(FLang[clRu, csOn], 'Lang_RuCaps'); + + FCaps := TDictionary.Create; + LoadResToDic(FCaps, 'Case'); + AddReverse(FCaps); + + FTrans := TDictionary.Create; + LoadResToDic(FTrans, 'Translit'); + + GetFontList(cbFont.Items); + SetDefaultSettings; + LoadSettings; +end; + +procedure TfrmMain.FormDestroy(Sender: TObject); +var i: TFormatAction; +begin + SaveSettings; + for i := Low(TFormatAction) to High(TFormatAction) do + if FRegistredHotkey[i] then + begin + UnregisterHotKey(Handle, HK_ID[i]); + FRegistredHotkey[i] := False; + end; + + FreeAndNil(FLang[clEn, csOff]); + FreeAndNil(FLang[clEn, csOn]); + FreeAndNil(FLang[clRu, csOff]); + FreeAndNil(FLang[clRu, csOn]); + FreeAndNil(FCaps); + FreeAndNil(FTrans); +end; + +function TfrmMain.GetColor(img: TImage): TColor; +begin + Result := img.Picture.Bitmap.Canvas.Pixels[0, 0]; +end; + +procedure TfrmMain.hkCodeAlignerChange(Sender: TObject); +begin + RegHK(faCodeVertical, hkCodeAligner.HotKey, hkCodeAligner.Modifiers); + imgHKList.GetIcon(HK_IconIndex[FRegistredHotkey[faCodeVertical]], imgCodeAligner.Picture.Icon); +end; + +procedure TfrmMain.hkSwitchLangChange(Sender: TObject); +begin + RegHK(faSwitchLang, hkSwitchLang.HotKey, hkSwitchLang.Modifiers); + imgHKList.GetIcon(HK_IconIndex[FRegistredHotkey[faSwitchLang]], imgSwitchLang.Picture.Icon); +end; + +procedure TfrmMain.hkSwitchRegChange(Sender: TObject); +begin + RegHK(faSwitchReg, hkSwitchReg.HotKey, hkSwitchReg.Modifiers); + imgHKList.GetIcon(HK_IconIndex[FRegistredHotkey[faSwitchReg]], imgSwitchReg.Picture.Icon); +end; + +procedure TfrmMain.hkTranslitChange(Sender: TObject); +begin + RegHK(faTranslit, hkTranslit.HotKey, hkTranslit.Modifiers); + imgHKList.GetIcon(HK_IconIndex[FRegistredHotkey[faTranslit]], imgTranslit.Picture.Icon); +end; + +procedure TfrmMain.imgBackColorClick(Sender: TObject); +begin + ColorDialog1.Color := GetColor(imgBackColor); + if ColorDialog1.Execute then + SetColor(imgBackColor, ColorDialog1.Color); +end; + +procedure TfrmMain.imgFontColorClick(Sender: TObject); +begin + ColorDialog1.Color := GetColor(imgFontColor); + if ColorDialog1.Execute then + SetColor(imgFontColor, ColorDialog1.Color); +end; + +procedure TfrmMain.LoadSettings; +var reg: TRegistry; + n: Integer; +begin + reg := TRegistry.Create; + try + reg.RootKey := HKEY_CURRENT_USER; + if reg.KeyExists(REG_Key) then + begin + reg.OpenKeyReadOnly(REG_Key); + if reg.ValueExists(REG_Value_FontName) then + if reg.GetDataType(REG_Value_FontName) = rdString then + begin + n := cbFont.Items.IndexOf(reg.ReadString(REG_Value_FontName)); + if n <> -1 then cbFont.ItemIndex := n; + end; + + if reg.ValueExists(REG_Value_FontSize) then + if reg.GetDataType(REG_Value_FontSize) = rdInteger then + edFontSize.Value := reg.ReadInteger(REG_Value_FontSize); + + if reg.ValueExists(REG_Value_FontColor) then + if reg.GetDataType(REG_Value_FontColor) = rdInteger then + SetColor(imgFontColor, reg.ReadInteger(REG_Value_FontColor)); + + if reg.ValueExists(REG_Value_BackColor) then + if reg.GetDataType(REG_Value_BackColor) = rdInteger then + SetColor(imgBackColor, reg.ReadInteger(REG_Value_BackColor)); + + + if reg.ValueExists(REG_Value_Hotkey_SLang) then + if reg.GetDataType(REG_Value_Hotkey_SLang) = rdInteger then + hkSwitchLang.HotKey := reg.ReadInteger(REG_Value_Hotkey_SLang); + if reg.ValueExists(REG_Value_Modifier_SLang) then + if reg.GetDataType(REG_Value_Modifier_SLang) = rdInteger then + hkSwitchLang.Modifiers := THKModifiers(Byte(reg.ReadInteger(REG_Value_Modifier_SLang))); + + if reg.ValueExists(REG_Value_Hotkey_SCase) then + if reg.GetDataType(REG_Value_Hotkey_SCase) = rdInteger then + hkSwitchReg.HotKey := reg.ReadInteger(REG_Value_Hotkey_SCase); + if reg.ValueExists(REG_Value_Modifier_SCase) then + if reg.GetDataType(REG_Value_Modifier_SCase) = rdInteger then + hkSwitchReg.Modifiers := THKModifiers(Byte(reg.ReadInteger(REG_Value_Modifier_SCase))); + + if reg.ValueExists(REG_Value_Hotkey_Trans) then + if reg.GetDataType(REG_Value_Hotkey_Trans) = rdInteger then + hkTranslit.HotKey := reg.ReadInteger(REG_Value_Hotkey_Trans); + if reg.ValueExists(REG_Value_Modifier_Trans) then + if reg.GetDataType(REG_Value_Modifier_Trans) = rdInteger then + hkTranslit.Modifiers := THKModifiers(Byte(reg.ReadInteger(REG_Value_Modifier_Trans))); + + if reg.ValueExists(REG_Value_Hotkey_CodeVAlign) then + if reg.GetDataType(REG_Value_Hotkey_CodeVAlign) = rdInteger then + hkCodeAligner.HotKey := reg.ReadInteger(REG_Value_Hotkey_CodeVAlign); + if reg.ValueExists(REG_Value_Modifier_CodeVAlign) then + if reg.GetDataType(REG_Value_Modifier_CodeVAlign) = rdInteger then + hkCodeAligner.Modifiers := THKModifiers(Byte(reg.ReadInteger(REG_Value_Modifier_CodeVAlign))); + + if reg.ValueExists(REG_Value_EditorW) then + if reg.GetDataType(REG_Value_EditorW) = rdInteger then + FNewEditorW := reg.ReadInteger(REG_Value_EditorW); + + if reg.ValueExists(REG_Value_EditorH) then + if reg.GetDataType(REG_Value_EditorH) = rdInteger then + FNewEditorH := reg.ReadInteger(REG_Value_EditorH); + end; + finally + FreeAndNil(reg); + end; +end; + +procedure TfrmMain.ProcessBuffer(const action: TFormatAction); + function GetCStr: string; +// var c: TClipboard; + begin + try + Result := Clipboard.AsText; + except + on e: EClipboardException do + begin + Result := ''; + end; + end; + { + c := TClipboard.Create; + try + Result := c.AsText; + finally + c.Free; + end; + } + end; + + procedure SetCStr(const s: string); + var hMem: HGLOBAL; + Data: Pointer; + begin + hMem := GlobalAlloc(GMEM_MOVEABLE, (Length(s)+1)*SizeOf(Char)); + if hMem <> 0 then + begin + Data := GlobalLock(hMem); + if Assigned(Data) then + try + FillChar(Data^, (Length(s)+1)*SizeOf(Char), 0); + Move(s[1], Data^, Length(s)*SizeOf(Char)); + finally + GlobalUnlock(hMem); + end + else + Exit; + + if OpenClipboard(0) then + try + EmptyClipboard(); + SetClipboardData(CF_UNICODETEXT, hMem); + finally + CloseClipboard(); + end; + end; + end; + +var h: HWND; + i: Integer; + oldBuf, newBuf: string; + wasFormated: boolean; + formatedStr: string; + UpdateID: Cardinal; + ActiveLayout: TCurrentLang; + CapsState: TCapsState; +begin + h := GetForegroundWindow; + if IsWindow(h) then + begin + if action = faSwitchLang then + if not CanSwitchLayoutNow(h, ActiveLayout) then Exit; + + oldBuf := GetCStr; + SetCStr(''); + UpdateID := GetClipboardSequenceNumber; + try + SendCtrlKey(Ord('C')); + for i := 0 to 99 do + begin + if GetClipboardSequenceNumber > UpdateID then Break; + Sleep(10); + end; + newBuf := GetCStr; + if newBuf = '' then Exit; + + wasFormated := True; + case action of + faSwitchLang : begin + if GetKeyState(VK_CAPITAL)=1 then + CapsState := csOn + else + CapsState := csOff; + newBuf := SwitchSymbols(FLang[ActiveLayout, CapsState], newBuf); + DoSwitchLayout(h); + end; + faSwitchReg : newBuf := SwitchSymbols(FCaps, newBuf); + faTranslit : newBuf := ReplaceSymbols(FTrans, newBuf); + faCodeVertical: begin + wasFormated := DoVerticalFormat(h, newBuf, formatedStr); + if wasFormated then newBuf := formatedStr; + end; + end; + + if wasFormated then + begin + SetCStr(newBuf); + SetForegroundWindow(h); + SendCtrlKey(Ord('V')); + Sleep(500); + end; + finally + SetForegroundWindow(h); + SetCStr(oldBuf); + end; + end; +end; + +procedure TfrmMain.RegHK(const Action: TFormatAction; const Key: TShortCut; const Modifiers: THKModifiers); +var M: Cardinal; +begin + if FRegistredHotkey[Action] then + begin + UnregisterHotKey(Handle, HK_ID[Action]); + FRegistredHotkey[Action] := False; + end; + M := 0; + if hkAlt in Modifiers then M := M or MOD_ALT; + if hkCtrl in Modifiers then M := M or MOD_CONTROL; + if hkShift in Modifiers then M := M or MOD_SHIFT; + if hkExt in Modifiers then M := M or MOD_WIN; + if M = 0 then Exit; + if Key = 0 then Exit; + if Key = $8000 then Exit; + FRegistredHotkey[Action] := RegisterHotKey(Handle, HK_ID[Action], M, LoByte(Key)); +end; + +function TfrmMain.ReplaceSymbols(const Dic: TDictionary; const Src: string): string; +var i: Integer; + s: string; +begin + Result := ''; + for i := 1 to Length(src) do + if Dic.TryGetValue(src[i], s) then + Result := Result + s + else + Result := Result + src[i]; +end; + +procedure TfrmMain.SaveSettings; +var reg: TRegistry; +begin + reg := TRegistry.Create; + try + reg.RootKey := HKEY_CURRENT_USER; + if reg.OpenKey(REG_Key, True) then + begin + reg.WriteString(REG_Value_FontName, cbFont.Text); + reg.WriteInteger(REG_Value_FontSize, edFontSize.Value); + reg.WriteInteger(REG_Value_FontColor, GetColor(imgFontColor)); + reg.WriteInteger(REG_Value_BackColor, GetColor(imgBackColor)); + + reg.WriteInteger(REG_Value_Hotkey_SLang, hkSwitchLang.HotKey); + reg.WriteInteger(REG_Value_Modifier_SLang, Byte(hkSwitchLang.Modifiers)); + reg.WriteInteger(REG_Value_Hotkey_SCase, hkSwitchReg.HotKey); + reg.WriteInteger(REG_Value_Modifier_SCase, Byte(hkSwitchReg.Modifiers)); + reg.WriteInteger(REG_Value_Hotkey_Trans, hkTranslit.HotKey); + reg.WriteInteger(REG_Value_Modifier_Trans, Byte(hkTranslit.Modifiers)); + reg.WriteInteger(REG_Value_Hotkey_CodeVAlign, hkCodeAligner.HotKey); + reg.WriteInteger(REG_Value_Modifier_CodeVAlign, Byte(hkCodeAligner.Modifiers)); + + reg.WriteInteger(REG_Value_EditorW, FNewEditorW); + reg.WriteInteger(REG_Value_EditorH, FNewEditorH); + end; + finally + FreeAndNil(reg); + end; +end; + +procedure TfrmMain.SendCtrlKey(const VKey: Word); + procedure SendKeyInput(const VKey: Word; const UpEvent: Boolean); + var input: TInput; + begin + input.Itype := INPUT_KEYBOARD; + input.ki.wScan := 0; + input.ki.time := 0; + input.ki.dwExtraInfo := 0; + input.ki.wVk := VKey; + if UpEvent then input.ki.dwFlags := KEYEVENTF_KEYUP else input.ki.dwFlags := 0; + SendInput(1, input, SizeOf(input)); + end; +var RC, LC: Boolean; + RS, LS: Boolean; +begin + LS := GetAsyncKeyState(VK_LSHIFT) < 0; + RS := GetAsyncKeyState(VK_RSHIFT) < 0; + LC := GetAsyncKeyState(VK_LCONTROL) < 0; + RC := GetAsyncKeyState(VK_RCONTROL) < 0; + if LS then SendKeyInput(VK_LSHIFT, True); + if RS then SendKeyInput(VK_RSHIFT, True); + if LC then SendKeyInput(VK_LCONTROL, True); + if RC then SendKeyInput(VK_RCONTROL, True); + + SendKeyInput(VK_LCONTROL, False); + SendKeyInput(VKey, False); + SendKeyInput(VKey, True); + SendKeyInput(VK_LCONTROL, True); + + if LS then SendKeyInput(VK_LSHIFT, False); + if RS then SendKeyInput(VK_RSHIFT, False); + if LC then SendKeyInput(VK_LCONTROL, False); + if RC then SendKeyInput(VK_RCONTROL, False); +end; + +procedure TfrmMain.SetColor(img: TImage; color: TColor); +begin + img.Picture.Bitmap.Canvas.Pixels[0, 0] := color; +end; + +procedure TfrmMain.SetDefaultSettings; +var n: Integer; +begin + hkSwitchLang.HotKey := VK_PAUSE; + hkSwitchLang.Modifiers := [hkShift]; + hkSwitchLang.OnChange(hkSwitchLang); + + hkSwitchReg.HotKey := VK_SCROLL; + hkSwitchReg.Modifiers := [hkShift]; + hkSwitchReg.OnChange(hkSwitchReg); + + hkTranslit.HotKey := VK_SCROLL; + hkTranslit.Modifiers := [hkCtrl, hkShift]; + hkTranslit.OnChange(hkTranslit); + + hkCodeAligner.HotKey := Ord('D'); + hkCodeAligner.Modifiers := [hkCtrl, hkShift]; + hkCodeAligner.OnChange(hkCodeAligner); + + n := cbFont.Items.IndexOf('Consolas'); + if n = -1 then n := cbFont.Items.IndexOf('Courier New'); + if n = -1 then n := 0; + cbFont.ItemIndex := n; + + imgFontColor.Picture.Bitmap.PixelFormat := pf24bit; + imgFontColor.Picture.Bitmap.Width := 1; + imgFontColor.Picture.Bitmap.Height := 1; + imgFontColor.Picture.Bitmap.Canvas.Pixels[0,0] := clBlack; + + imgBackColor.Picture.Bitmap.PixelFormat := pf24bit; + imgBackColor.Picture.Bitmap.Width := 1; + imgBackColor.Picture.Bitmap.Height := 1; + imgBackColor.Picture.Bitmap.Canvas.Pixels[0,0] := clWhite; + + FNewEditorW := 750; + FNewEditorH := 250; +end; + +function TfrmMain.SwitchSymbols(const Dic: TDictionary; const Src: string): string; +var i: Integer; +begin + SetLength(Result, Length(Src)); + for i := 1 to Length(src) do + if not Dic.TryGetValue(src[i], Result[i]) then Result[i] := src[i]; +end; + +procedure TfrmMain.TrayIcon1Click(Sender: TObject); +begin + Show; + SetForegroundWindow(Handle); +end; + +procedure TfrmMain.WMHotkey(var msg: TWMHotKey); +var act: TFormatAction; +begin + case msg.HotKey of + HK_Base + 1: act := faSwitchLang; + HK_Base + 2: act := faSwitchReg; + HK_Base + 3: act := faTranslit; + HK_Base + 4: act := faCodeVertical; + else + Exit; + end; + ProcessBuffer(act); +end; + +end.