keyboardfreak
Joined: 09 Oct 2004 Posts: 143 Location: Budapest, Hungary
|
Posted: Tue Jul 15, 2008 10:04 am Post subject: Restoring recently deleted text |
|
|
Sometimes I delete chunks of text which I regret later and I want to restore them. Undo is useful for that, but the problem is often I've already written more text since the deletion, so undo reverts those in-between changes too which I would like to keep.
The script below monitors if a selected part of the text is deleted and if so then it stores the selection first before sending the delete key.
With ctrl+delete one can restore a few recent deletions.
Note the script is only a proof of concept. It's very unpolished. For example, it shows only several stored items even if there are more available, because I used an inputbox due to lazyness.
I put it here only as an example. Someone may get interested and develop the idea properly:
| Code: | max_items := 10
items := 0
current := 0
$delete::
oldclip := clipboard
sendinput ^c
if (clipboard <> oldclip)
{
items%current% := clipboard
items += 1
if (items > max_items)
items := max_items
current += 1
if (current = max_items)
current = 0
}
clipboard := oldclip
sendinput {delete}
return
^delete::
if (items = 0)
{
msgbox no items
return
}
start := current
msg = Choose an item:`n`n
loop % items
{
start -= 1
if (start = -1)
start := max_items - 1
msg := msg . start . " - " . items%start% . "`n"
}
InputBox, input, Restore deletion, %msg%
if not ErrorLevel
{
oldclip := clipboard
clipboard := items%input%
sendinput ^v
clipboard := oldclip
}
return
|
|
|