Skip to content

Commit

Permalink
- Fixed highlighting two sections in a row in autohotkey backend
Browse files Browse the repository at this point in the history
- Added :. to immediately move the carret to the current section (otherwise by default it'll happen just before the insertion)
  • Loading branch information
iarwain committed Jul 5, 2020
1 parent 6ea0607 commit 3be47ba
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions text2key.r
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ autohotkey: make backend [
emit rejoin [{Sleep } to-integer 1000 * to-decimal duration]
]
highlight: func [delta] [
if highlight-count != 0 [
emit either highlight-count > 0 [{SendEvent {Left}}] [{SendEvent {Right}}]
highlight-count: 0
]
if remove-count != 0 [
emit rejoin [{SendEvent {Shift Down}^{Down } remove-count {^}{Shift Up}{Delete}}]
remove-count: 0
]
emit rejoin [{SendEvent {Shift Down}^{} pick [{Down } {Up }] delta > 0 abs delta {^}{Shift Up}}]
highlight-count: delta
]
Expand All @@ -80,16 +88,16 @@ autohotkey: make backend [
emit {SetKeyDelay %A_KeyDelay%, 100}
emit {SendEvent {Insert}}
emit {SetKeyDelay %A_KeyDelay%, 0}
remove-count: remove-count - 1
remove-data: next remove-data
] [
emit rejoin [{S("} replace/all replace/all system/words/copy line {;} {`;} {"} {""} {`n} {")}]
]
remove-count: remove-count - 1
remove-data: next remove-data
]
if remove-count > 0 [
emit rejoin [{SendEvent {Shift Down}^{Down } remove-count {^}{Shift Up}{Delete}}]
remove-count: 0
]
remove-count: 0
] [
if carry: to-logic all [current < length? data not empty? lines not empty? data/:current] [
emit {SendEvent {Text}`n}
Expand Down Expand Up @@ -119,11 +127,6 @@ autohotkey: make backend [
]
emit rejoin [uppercase value {::}]
]
window: func [value] [
emit {SetTitleMatchMode, 2}
emit reform [{WinWait,} replace value #"@" " ahk_exe "]
emit reform [{WinActivate,} replace value #"@" " ahk_exe "]
]
move: func [delta] [
if highlight-count != 0 [
emit either highlight-count > 0 [{SendEvent {Left}}] [{SendEvent {Right}}]
Expand Down Expand Up @@ -159,6 +162,11 @@ autohotkey: make backend [
emit reform [either find value #"@" [{ControlSend, ahk_parent,}] [{Send}] replace value #"@" ", ahk_exe "]
emit {SetKeyDelay %A_KeyDelay%, 0}
]
window: func [value] [
emit {SetTitleMatchMode, 2}
emit reform [{WinWait,} replace value #"@" " ahk_exe "]
emit reform [{WinActivate,} replace value #"@" " ahk_exe "]
]
]

; === Log ===
Expand Down Expand Up @@ -188,6 +196,7 @@ either attempt [exists? file: to-rebol-file system/options/args/1] [
| #"!" (action: 'save)
| #"%" (action: 'send) spaces copy arg any option-value (arg: trim arg)
| #"@" (action: 'window) spaces copy arg any option-value (arg: trim arg)
| #"." (action: 'move)
| #"-" (actions: post-actions)
] opt [copy arg label (arg: load arg)]
]
Expand Down Expand Up @@ -264,15 +273,14 @@ either attempt [exists? file: to-rebol-file system/options/args/1] [
target: find-line/with arg step
print [{ . Copying from [} arg {]} sections/(to-string arg)/line-count {lines at line} target]
]
window [
print [{ . Focusing window [} arg {]}]
exporter/window arg
]
highlight [
target: find-line/with arg step
print [{ . Highlighting to beginning of [} arg {], line} target]
exporter/highlight target - exporter/current
]
move [
move-to find-line step
]
pause [
print [{ . Pausing} arg {seconds}]
exporter/pause arg
Expand Down Expand Up @@ -306,6 +314,10 @@ either attempt [exists? file: to-rebol-file system/options/args/1] [
print [{ . Sending [} arg {]}]
exporter/send arg
]
window [
print [{ . Focusing window [} arg {]}]
exporter/window arg
]
]
]
] section/pre-actions
Expand Down

0 comments on commit 3be47ba

Please sign in to comment.