Replacement of abbreviations (tool)

Everything else that doesn't fall into one of the other PB categories.
AZJIO
Addict
Addict
Posts: 1298
Joined: Sun May 14, 2017 1:48 am

Replacement of abbreviations (tool)

Post by AZJIO »

Previously, I wrote a TextCorrection program for Windows. It has a useful functionality for programming "replacement of abbreviations". You enter a short word, press a hot key and it is replaced with your text version.

Here is an example of a Replace.ini file:

Code: Select all

; Texts
npp=Notepad++
pb=PureBasic
sci=Scintilla
g2=Grub2
g4d=Grub4Dos
pe=WinPE
-=—
—=-

; PureBasic
proc=Procedure Name()~	Protected~	~	ProcedureReturn~EndProcedure~
func=Procedure Name()~	Protected~	~	ProcedureReturn~EndProcedure~
prot=Protected
de=Debug
gui=~If OpenWindow(0, 0, 0, 220, 100, "Пример...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)~	ButtonGadget  (1, 10, 60, 200, 30, "Закрыть")~~	Repeat~		Select WaitWindowEvent()~			Case #PB_Event_Gadget~				Select EventGadget()~					Case 1~						CloseWindow(0)~						End~				EndSelect~			Case #PB_Event_CloseWindow~				CloseWindow(0)~				End~		EndSelect~	ForEver~~EndIf~
win=~If OpenWindow(0, 0, 0, 220, 100, "Пример...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)~	ButtonGadget  (1, 10, 60, 200, 30, "Закрыть")~~	Repeat~		Select WaitWindowEvent()~			Case #PB_Event_Gadget~				Select EventGadget()~					Case 1~						CloseWindow(0)~						End~				EndSelect~			Case #PB_Event_CloseWindow~				CloseWindow(0)~				End~		EndSelect~	ForEver~~EndIf~
mr=MessageRequester("Message", "Text")
mr2=MessageRequester(Message, Text)
fe=ForEach List()~	~Next
sel=~Select Value~	Case 1~		Debug "Value = 1"~	Default~		Debug "не знаю"~EndSelect~
ww=~While 1~	Delay(1000)~WEnd~
ru=~Repeat~	Delay(1000)~Until 0~
ret=ProcedureReturn
if=~If expression~	result~EndIf~
ifn=~If Not expression~	result~EndIf~
iff=~If FileSize(file) > -1~	result~EndIf~
rs=Text$ = ReplaceString(Text$, "Find", "Replace")
fs=pos = FindString(Text$, "Find")
inc=XIncludeFile "file.pb"

; BBCode
blink=[url=][/url]
bred=[color=#FF000][/color]

; HTML
hstyle=<style>~~</style>
hlist=<ul>~<li>item</li>~</ul>
hlistn=<ol>~<li>item</li>~</ol>
htable=<table class="param" cellspacing="0" cellpadding="3">~<tr>~<td></td>~</tr>~</table>
font=<font size="+1">текст</font>
hlink=<a href="линк.htm">Имя</a>
<=&lt;
>=&gt;
rem=<!--~~-->
; mnemonic code
space=&nbsp;
dia=&Oslash;
arrow=&rarr;
Here, the tilde (~) is replaced with a line break (CRLF), which allows you to insert multi-line code snippets.
I think it's not difficult to write a tool in PureBasic, repeating the functionality.
In my case, I use Russian words to make typing easier.
Axolotl
Enthusiast
Enthusiast
Posts: 432
Joined: Wed Dec 31, 2008 3:36 pm

Re: Replacement of abbreviations (tool)

Post by Axolotl »

Hey AZJIO,
thanks for sharing.
I also use a lot of abbreviations/shortcuts, but I do it with HotString in AutoHotkey.
Maybe your tool is something for me when I will do more with linux in the future?
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
AZJIO
Addict
Addict
Posts: 1298
Joined: Sun May 14, 2017 1:48 am

Re: Replacement of abbreviations (tool)

Post by AZJIO »

Axolotl
Yes, I did it for Linux too, but automatic selection of text from the cursor to the left is not so reliable and I have to select it manually (Ctrl + Shift + Left), and then call the hotkey.
Post Reply