Permalink
Browse files

Pulled chunks of code into separate files in the includes directory p…

…er Dustin's suggestion and my long-time putting it off. Should help keep the code cleaner and more modular.
  • Loading branch information...
1 parent 859e128 commit 66acc37a7925669b3004933b0a75224078d6b064 adam committed Sep 21, 2007
View
@@ -0,0 +1,23 @@
+ABOUT:
+Gui,4: Destroy
+Gui,4: +owner2
+Gui,4: Add,Picture,x200 y0,%TexterPNG%
+Gui,4: font, s36, Courier New
+Gui,4: Add, Text,x10 y35,Texter
+Gui,4: font, s8, Courier New
+Gui,4: Add, Text,x171 y77,%Version%
+Gui,4: font, s9, Arial
+Gui,4: Add,Text,x10 y110 Center,Texter is a text replacement utility designed to save`nyou countless keystrokes on repetitive text entry by`nreplacing user-defined abbreviations (or hotstrings)`nwith your frequently-used text snippets.`n`nTexter is written by Adam Pash and distributed`nby Lifehacker under the GNU Public License.`nFor details on how to use Texter, check out the
+Gui,4:Font,underline bold
+Gui,4:Add,Text,cBlue gHomepage Center x110 y230,Texter homepage
+Gui,4: Color,F8FAF0
+Gui 2:+Disabled
+Gui,4: Show,auto,About Texter
+Return
+
+4GuiClose:
+4GuiEscape:
+DismissAbout:
+Gui 2:-Disabled
+Gui,4: Destroy
+return
View
@@ -0,0 +1,27 @@
+HELP:
+Gui,5: Destroy
+Gui,5: Add,Picture,x200 y5,%TexterPNG%
+Gui,5: font, s36, Courier New
+Gui,5: Add, Text,x20 y40,Texter
+Gui,5: font, s9, Arial
+Gui,5: Add,Text,x19 y285 w300 center,All of Texter's documentation can be found online at the
+Gui,5:Font,underline bold
+Gui,5:Add,Text,cBlue gHomepage Center x125 y305,Texter homepage
+Gui,5: font, s9 norm, Arial
+Gui,5: Add,Text,x10 y100 w300,For help by topic, click on one of the following:
+Gui,5:Font,underline bold
+Gui,5:Add,Text,x30 y120 cBlue gBasicUse,Basic Use:
+Gui,5:Font,norm
+Gui,5:Add,Text,x50 y140 w280, Covers how to create basic text replacement hotstrings.
+Gui,5:Font,underline bold
+Gui,5:Add,Text,x30 y180 cBlue gScripting,Sending advanced keystrokes:
+Gui,5:Font,norm
+Gui,5:Add,Text,x50 y200 w280, Texter is capable of sending advanced keystrokes, like keyboard combinations. This section lists all of the special characters used in script creation, and offers a few examples of how you might use scripts.
+Gui,5: Color,F8FAF0
+Gui,5: Show,auto,Texter Help
+Return
+
+5GuiEscape:
+DismissHelp:
+Gui,5: Destroy
+return
@@ -0,0 +1,228 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Implementation and GUI for management ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+MAINWINTOOLBAR:
+Menu, ToolsMenu, Add, P&references..., Preferences
+Menu, MgmtMenuBar, Add, &Tools, :ToolsMenu
+Menu, BundlesMenu, Add, &Export, Export
+Menu, BundlesMenu, Add, &Import, Import
+Menu, BundlesMenu, Add, &Add, AddBundle
+Menu, BundlesMenu, Add, &Remove, DeleteBundle
+Menu, MgmtMenuBar, Add, &Bundles, :BundlesMenu
+Menu, HelpMenu, Add, &Basic Use, BasicUse
+Menu, HelpMenu, Add, Ad&vanced Use, Scripting
+Menu, HelpMenu, Add, &Homepage, Homepage
+Menu, HelpMenu, Add, &About..., About
+Menu, MgmtMenuBar, Add, &Help, :HelpMenu
+Gui,2: Menu, MgmtMenuBar
+return
+
+MANAGE:
+Gui,2: Destroy
+Gosub,MAINWINTOOLBAR
+GoSub,GetFileList
+Bundles =
+Loop,bundles\*,2
+{
+ Bundles = %Bundles%|%A_LoopFileName%
+ thisBundle = %A_LoopFileName%
+; Loop,bundles\%A_LoopFileName%\replacements\*.txt
+; {
+; thisReplacement:=Dehexify(A_LoopFileName)
+; thisBundle = %thisBundle%%thisReplacement%|
+; }
+ StringReplace, thisBundle, thisBundle, .txt,,All
+ StringReplace, thisBundle, thisBundle, %A_LoopFileName%,,
+ %A_LoopFileName% = %thisBundle%
+}
+StringReplace, FileList, FileList, .txt,,All
+StringTrimLeft,Bundles,Bundles,1
+Gui,2: Default
+Gui,2: Font, s12, Arial
+Gui,2: Add,Tab,x5 y5 h390 w597 vBundleTabs gListBundle,Default|%Bundles% ;;;;;; START ADDING BUNDLES
+Gui,2: Add, Text, Section,
+Gui,2: Tab ;;; Every control after this point belongs to no individual tab
+Gui,2: Add, Text,ys xs,Hotstring:
+Gui,2: Add, ListBox, xs r15 W100 vChoice gShowString Sort, %FileList%
+Gui,2: Add, Button, w35 xs+10 GAdd,+
+Gui,2: Add, Button, w35 xp+40 GDelete,-
+Gui,2: Add, DropDownList, Section ys vTextOrScript, Text||Script
+Gui,2: Font, s12, Arial
+Gui,2: Add, Edit, r12 W460 xs vFullText
+Gui,2: Add, Text, xs,Trigger:
+Gui,2: Add, Checkbox, vEnterCbox yp xp+65, Enter
+Gui,2: Add, Checkbox, vTabCbox yp xp+65, Tab
+Gui,2: Add, Checkbox, vSpaceCbox yp xp+60, Space
+Gui,2: Font, s8, Arial
+Gui,2: Add,Button, w80 GPButtonSave xs+375 yp, &Save
+IniRead,bundleCheck,texter.ini,Bundles,Default
+Gui,2: Add, Checkbox, Checked%bundleCheck% vbundleCheck gToggleBundle xs+400 yp+50,Enabled
+Gui,2: Add, Button, w80 Default GPButtonOK xs+290 yp+30,&OK
+Gui,2: Add, Button, w80 xp+90 GPButtonCancel, &Cancel
+Gui,2: Show, , Texter Management
+Hotkey,IfWinActive, Texter Management
+Hotkey,!p,Preferences
+Hotkey,delete,Delete
+Hotkey,IfWinActive
+return
+
+ListBundle:
+if A_GuiControl = BundleTabs
+ GuiControlGet,CurrentBundle,2:,BundleTabs
+IniRead,bundleCheck,texter.ini,Bundles,%CurrentBundle%
+GuiControl,2:,Choice,|
+Loop,bundles\*,2
+{
+ Bundles = %Bundles%|%A_LoopFileName%
+ thisBundle = %A_LoopFileName%
+ Loop,bundles\%A_LoopFileName%\replacements\*.txt
+ {
+ thisReplacement:=Dehexify(A_LoopFileName)
+ thisBundle = %thisBundle%%thisReplacement%|
+ }
+; StringReplace, thisBundle, thisBundle, .txt,,All
+ StringReplace, thisBundle, thisBundle, %A_LoopFileName%,,
+ %A_LoopFileName% = %thisBundle%
+}
+;if A_GuiControl = Tab
+; GuiControl,,Choice,|
+;else
+; GuiControl,,Choice,%RString%||
+GuiControl,2:,FullText,
+GuiControl,2:,EnterCbox,0
+GuiControl,2:,TabCbox,0
+GuiControl,2:,SpaceCbox,0
+GuiControl,2:,bundleCheck,%bundleCheck%
+if CurrentBundle = Default
+{
+ Gosub,GetFileList
+ CurrentBundle = %FileList%
+ GuiControl,,Choice,%CurrentBundle%
+}
+else
+{
+ StringTrimLeft,CurrentBundle,%CurrentBundle%,0
+ GuiControl,2:,Choice,%CurrentBundle%
+}
+return
+
+ToggleBundle:
+GuiControlGet,CurrentBundle,,BundleTabs
+GuiControlGet,bundleCheck,,bundleCheck
+IniWrite,%bundleCheck%,texter.ini,Bundles,%CurrentBundle%
+Gosub,BuildActive
+return
+
+ADD:
+EnableTriggers(false)
+GoSub,Newkey
+IfWinExist,Add new hotstring...
+{
+ WinWaitClose,Add new hotstring...,,
+}
+;GoSub,GetFileList
+GoSub,ListBundle
+StringReplace, CurrentBundle, CurrentBundle,|%RString%|,|%RString%||
+GuiControl,,Choice,|%CurrentBundle%
+EnableTriggers(true)
+GoSub,ShowString
+return
+
+DELETE:
+Gui 2:+OwnDialogs
+GuiControlGet,ActiveChoice,,Choice
+GuiControlGet,CurrentBundle,,BundleTabs
+if (CurrentBundle != "") and (CurrentBundle != "Default")
+ RemoveFromDir = Bundles\%CurrentBundle%\
+else
+ RemoveFromDir =
+
+MsgBox,1,Confirm Delete,Are you sure you want to delete this hotstring: %ActiveChoice%
+IfMsgBox, OK
+{
+ ActiveChoice:=Hexify(ActiveChoice)
+ FileDelete,%A_ScriptDir%\%RemoveFromDir%replacements\%ActiveChoice%.txt
+ DelFromBank(ActiveChoice, RemoveFromDir, "enter")
+ DelFromBank(ActiveChoice, RemoveFromDir, "tab")
+ DelFromBank(ActiveChoice, RemoveFromDir, "space")
+ GoSub,ListBundle
+ Gosub,BuildActive
+ GuiControl,,Choice,|%CurrentBundle%
+ GuiControl,,FullText,
+ GuiControl,,EnterCbox,0
+ GuiControl,,TabCbox,0
+ GuiControl,,SpaceCbox,0
+}
+return
+
+ShowString:
+GuiControlGet,ActiveChoice,,Choice
+ActiveChoice:=Hexify(ActiveChoice)
+GuiControlGet,CurrentBundle,,BundleTabs
+if CurrentBundle = Default
+ ReadFrom =
+else
+ ReadFrom = bundles\%CurrentBundle%\
+
+FileRead,enter,%ReadFrom%bank\enter.csv
+FileRead,tab,%ReadFrom%bank\tab.csv
+FileRead,space,%ReadFrom%bank\space.csv
+
+if ActiveChoice in %enter%
+{
+ GuiControl,,EnterCbox,1
+}
+else
+ GuiControl,,EnterCbox,0
+if ActiveChoice in %tab%
+{
+ GuiControl,,TabCbox,1
+}
+else
+ GuiControl,,TabCbox,0
+if ActiveChoice in %space%
+{
+ GuiControl,,SpaceCbox,1
+}
+else
+ GuiControl,,SpaceCbox,0
+FileRead, Text, %ReadFrom%replacements\%ActiveChoice%.txt
+IfInString,Text,::scr::
+{
+ GuiControl,,TextOrScript,|Text|Script||
+ StringReplace,Text,Text,::scr::,,
+}
+else
+ GuiControl,,TextOrScript,|Text||Script
+GuiControl,,FullText,%Text%
+return
+
+PButtonSave:
+Gui,2: Submit, NoHide
+IsScript := (TextOrScript == "Script")
+
+If Choice <>
+{
+ if (CurrentBundle != "") and (CurrentBundle != "Default")
+ SaveToDir = Bundles\%CurrentBundle%\
+ else
+ SaveToDir =
+ PSaveSuccessful := SaveHotstring(Choice, FullText, IsScript, SaveToDir, SpaceCbox, TabCbox, EnterCbox)
+}
+else
+{
+ PSaveSuccessful = true
+}
+return
+
+2GuiEscape:
+PButtonCancel:
+Gui,2: Destroy
+return
+
+PButtonOK:
+Gosub,PButtonSave
+if PSaveSuccessful
+{
+ Gui,2: Submit
+ Gui,2: Destroy
+}
+return
@@ -0,0 +1,59 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Implementation and GUI for on-the-fly creation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+NEWKEY:
+if A_GuiControl = + ;;;; MAYBE CHANGE THIS TO IfWinExist,Texter Management
+ GuiControlGet,CurrentBundle,,BundleTabs
+else
+ CurrentBundle =
+if (CurrentBundle != "") and (CurrentBundle != "Default")
+ AddToDir = Bundles\%CurrentBundle%\
+else
+ AddToDir =
+Gui,1: Destroy
+IniRead,EnterBox,texter.ini,Triggers,Enter
+IniRead,TabBox,texter.ini,Triggers,Tab
+IniRead,SpaceBox,texter.ini,Triggers,Space
+Gui,1: font, s12, Arial
+Gui,1: +owner2 +AlwaysOnTop -SysMenu +ToolWindow ;suppresses taskbar button, always on top, removes minimize/close
+Gui,1: Add, Text,x10 y20, Hotstring:
+Gui,1: Add, Edit, x13 y45 r1 W65 vRString,
+Gui,1: Add, Edit, x100 y45 r4 W395 vFullText, Enter your replacement text here...
+Gui,1: Add, Text,x115,Trigger:
+Gui,1: Add, Checkbox, vEnterCbox yp x175 Checked%EnterBox%, Enter
+Gui,1: Add, Checkbox, vTabCbox yp x242 Checked%TabBox%, Tab
+Gui,1: Add, Checkbox, vSpaceCbox yp x305 Checked%SpaceBox%, Space
+Gui,1: font, s8, Arial
+Gui,1: Add, Button,w80 x320 default,&OK
+Gui,1: Add, Button,w80 xp+90 GButtonCancel,&Cancel
+Gui,1: font, s12, Arial
+Gui,1: Add,DropDownList,x100 y15 vTextOrScript, Text||Script
+Gui,1: Add,Picture,x0 y105,%TexterPNG%
+Gui 2:+Disabled
+Gui,1: Show, W500 H200,Add new hotstring...
+return
+
+GuiEscape:
+ButtonCancel:
+Gui 2:-Disabled
+Gui,1: Destroy
+return
+
+ButtonOK:
+Gui,1: Submit, NoHide
+Gui 1:+OwnDialogs
+hexRString:=hexify(RString)
+IfExist, %A_ScriptDir%\%AddToDir%replacements\%hexRString%.txt
+{
+ MsgBox,262144,Hotstring already exists, A replacement with the text %RString% already exists. Would you like to try again?
+ return
+}
+IsScript := (TextOrScript == "Script")
+
+if SaveHotstring(RString, FullText, IsScript, AddToDir, SpaceCbox, TabCbox, EnterCbox)
+{
+ Gui 2:-Disabled
+ Gui,1: Submit
+}
+Gosub,GetFileList
+return
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End Implementation and GUI for on-the-fly creation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Oops, something went wrong.

0 comments on commit 66acc37

Please sign in to comment.