Implement textexpander's macros
This MR implements "macros", proposed in issue #5 (closed), which allow for more complex actions than just simple text insertion. Specifically, it implements:
-
%key:⟨keysym⟩%1, which simulates pressing that key -
%|2, the "cursor position macro", moves the cursor to that part of the expansion after the text is expanded. -
%\3, which selects from wherever%|was to "here".
Closes #5 (closed).
To Draft
-
%key:⟨keysym⟩%1, which simulates pressing that key -
%|2, the "cursor position macro", moves the cursor to that part of the expansion after the text is expanded. -
%\3, which selects from wherever%|was to "here". -
%%3, which expands a single percent character (escape) (if needed)
Wasn't needed (see thread) -
Error checking code that returns an error when %|and%\aren't the last-seen macros -
Expand the README describing how to use these new macros
To Test
View Test Cases
macro_key_test_1: "Key[A]: %key:A%, Key[B]: %key:B%"
macro_key_test_2: "-->Key[TAB]: %key:Tab%<--"
macro_key_test_3: MyUserName%key:Tab%MyPassWord
cursor_test_1: "%|<--- Cursor should be here"
cursor_test_2: "Cursor --> %| <----"
cursor_test_3: |2-
My Name is Frank
My Name is %|Joseph
My Name is Abigail
highlight_test_1: '--> %\highlighted'
highlight_test_2: 'The %|word%\ "word" should be highlighted'
invalid_macro_test_1: 'Key[A]: %key:A%, Cursor: %|, Key[B]: %key:B%'
invalid_macro_test_2: 'Key[A]: %key:A%, Cursor: %|, Key[B]: %key:B%, Highlight: %\'
-
%key:⟨keysym⟩%1 -
%|2-
Passes cursor_test_1 -
Passes cursor_test_2 -
Passes cursor_test_3
-
-
%\3-
Passes highlight_test_1 -
Passes highlight_test_2
-
-
Wasn't needed (see thread)%%3 -
Error checking code that returns an error when %|and%\aren't the last-seen macros-
Passes invalid_macro_test_1 -
Passes invalid_macro_test_2
-
To Debug
-
It looks like texpander inserts a newline after the snippet now for one line snippets, which I should fix. -
It also looks like xdotoolisn't quite working yet forkey. -
After being read, the macro_queuearray ends up having a ton of weird whitespace in it -
Sometimes text is being sliced off too early by the macro (see below thread) -
It looks like partitions after the first aren't correctly being inserted? (see below thread)
View State Diagram
stateDiagram
proc : Start processing the macros
mkq : make a priority queue to put the macros in
c1 : Still macros in text?
cm : Consider the macro closest to the start of the text
ri : Push where it starts in the text onto the queue
sr : Store that number somewhere
dl : Delete the macro's text
% toplevel
[*] --> mkq
mkq --> proc
% Process Macros
proc --> c1
c1 --> c2 : [No]
c1 --> cm : [Yes]
cm --> ri
ri --> sr
sr --> dl
dl --> c1
% Execute Macros
pstrst : Paste rest of text
c2 : Macro Queue Empty?
pm : Pop a macro from the queue
pst : Paste text up until the macro's index
ex : Execute the macro
c2 --> pstrst : [Yes]
pstrst --> [*]
c2 --> pm : [No]
pm --> pst
pst --> ex
ex --> c2
note right of mkq
Priority will be based off of the closeness
to beginning of text, and the order of
execution. The order of execution should
be as follows.
1. %key
2. %|
3. %\
end note
Edited by MyriaCore