Skip to content

Commit

Permalink
New: AltPaste, addition to define PasteDelay (ms) and PasteMethod (0-…
Browse files Browse the repository at this point in the history
…2) per program
  • Loading branch information
lintalist committed Sep 29, 2022
1 parent 8271bdf commit 21a692e
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 29 deletions.
5 changes: 5 additions & 0 deletions changelog.md
@@ -1,3 +1,8 @@
### v1.9.16

* New: AltPaste, addition to define PasteDelay (ms) and PasteMethod (0-2) per program
* Fix: Fix the change so it actually restores Clipboard contents https://github.com/lintalist/lintalist/issues/217 (line '970' was omitted from commit)

### v1.9.15

* New: Allow for _ in MyFunction and MyPlugin names https://github.com/lintalist/lintalist/issues/221
Expand Down
2 changes: 2 additions & 0 deletions docs/AltPaste.md
Expand Up @@ -23,6 +23,8 @@ Use the name of the program executable as [section] name, followed by one or mor
- Cut= alternative cut shortcut +{Del} for console applications
- Paste= alternative paste shortcut +{Ins} for console applications
- QuickSearch= alternative shortcut to Select and Cut Word to the Left of the Caret position
- PasteDelay= see documentation, delay in milliseconds, overrides global setting
- PasteMethod= 0-2, see documentation, overrides global setting

Only add those keys you need for that application.
Restart Lintalist after modifying `AltPaste.ini`
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -87,7 +87,7 @@
</div>

<div class='column'>
<p><b>Download Lintalist <em>1.9.15</em></b>
<p><b>Download Lintalist <em>1.9.16</em></b>
<p>
<a href='https://github.com/lintalist/lintalist/releases'><img src='img/lintalist65x65.gif' alt='Download Lintalist' width='65' align='left' border='0' style='margin-right: 5px;' /></a>
Download (incl. source):<br />
Expand Down
10 changes: 8 additions & 2 deletions include/Default.ahk
Expand Up @@ -65,6 +65,8 @@ SendKey(Method = 1, Keys = "")

global PasteDelay, ActiveWindowID, ActiveControl, ActiveWindowProcessName, AltPaste, ShortcutCopy, ShortcutPaste, ShortcutCut, ShortcutQuickSearch

UsePasteDelay:=PasteDelay

; replace default keys with application specific keys defined in AltPaste.ini - see docs\AltPaste.md
If ActiveWindowProcessName in % AltPaste.programs
{
Expand All @@ -88,6 +90,10 @@ SendKey(Method = 1, Keys = "")
if AltPaste[ActiveWindowProcessName].HasKey("QuickSearch")
keys:=AltPaste[ActiveWindowProcessName].QuickSearch
}

if AltPaste[ActiveWindowProcessName].HasKey("PasteDelay")
UsePasteDelay:=AltPaste[ActiveWindowProcessName].PasteDelay

}

; If ((Save = 1) or (Save = ""))
Expand Down Expand Up @@ -116,10 +122,10 @@ SendKey(Method = 1, Keys = "")
}

; Sleep 50 ; some time to get data to clipboard
Sleep, % PasteDelay ; was at the start of the function, moved it here
Sleep, % UsePasteDelay ; was at the start of the function, moved it here

; Because one of the includes below will always fail code is only loaded once:
#include *i %A_ScriptDir%\include\AfterPaste.ahk ; from lintastlist search
#include *i %A_ScriptDir%\include\AfterPaste.ahk ; from lintalist search
#include *i %A_ScriptDir%\..\include\AfterPaste.ahk ; from a script

; If (Restore = 1)
Expand Down
2 changes: 1 addition & 1 deletion include/Markdown2HTML.ahk
Expand Up @@ -11,7 +11,7 @@ Source: https://github.com/fincs/GenDocs
using a ~~~ block HTML-code is included as is
See documentation "Formatted Text Snippets", "Markdown" for more information on tables
and how to use the simplyfied version of the Markdown syntax that is supported by
and how to use the simplified version of the Markdown syntax that is supported by
this function.
*/
Expand Down
34 changes: 26 additions & 8 deletions include/ReadAltPasteIni.ahk
@@ -1,13 +1,22 @@
; LintaList Include
; Purpose: Read AltPaste INI
; Version: 1.0
; Date: 20180817
/*
LintaList Include
Purpose: Read AltPaste INI
Version: 1.1
Date: 20220929
History:
1.1 PasteDelay, PasteMethod added #230
1.0 Initial version 20180817
Ini format:
/*
[program.exe]
Copy=^{Ins}
Cut=+{Del}
Paste=+{Ins}
QuickSearch=
PasteDelay=ms
PasteMethod=0-2
*/

ReadAltPasteIni()
Expand All @@ -20,7 +29,7 @@ ReadAltPasteIni()
; IniRead, OutputVar, Filename, Section, Key [, Default]
IniRead, SectionNames, %ini%
AltPaste:={}
keys:="copy,cut,paste,QuickSearch"
keys:="copy,cut,paste,QuickSearch,PasteDelay,PasteMethod"
AltPaste["programs"]:=Trim(StrReplace(SectionNames,"`n",","),",")
Loop, parse, SectionNames, `n
{
Expand All @@ -35,7 +44,11 @@ ReadAltPasteIni()
AltPaste[section,"paste"]:=paste
if QuickSearch
AltPaste[section,"QuickSearch"]:=QuickSearch
copy:="",cut:="",paste:="",QuickSearch:=""
if PasteDelay
AltPaste[section,"PasteDelay"]:=PasteDelay
if PasteMethod
AltPaste[section,"PasteMethod"]:=PasteMethod
copy:="",cut:="",paste:="",QuickSearch:="",PasteDelay:="",PasteMethod:=""
}
}

Expand All @@ -52,8 +65,13 @@ FileAppend,
; copy=
; cut=
; paste=
; Use AHK notation (^=ctrl +=shift !=alt) for the shortcuts.
; QuickSearch= see documentation (cut word to the left, start Lintalist Search Gui)
;
; Use AHK notation (^=ctrl +=shift !=alt) for the above shortcuts.
;
; PasteDelay= see documentation, delay in milliseconds, overrides global setting
; PasteMethod=0-2, see documentation, overrides global setting
;
; IBM Common User Access (CUA) standard:
; Copy : Control+Insert -> ^{Ins}
; Cut : Shift+Delete -> +{Del}
Expand Down
35 changes: 19 additions & 16 deletions lintalist.ahk
Expand Up @@ -4,7 +4,7 @@ Name : Lintalist
Author : Lintalist
Purpose : Searchable interactive lists to copy & paste text, run scripts,
using easily exchangeable bundles
Version : 1.9.15
Version : 1.9.16
Code : https://github.com/lintalist/
Website : http://lintalist.github.io/
AutoHotkey Forum: https://autohotkey.com/boards/viewtopic.php?f=6&t=3378
Expand Down Expand Up @@ -42,7 +42,7 @@ PluginMultiCaret:=0 ; TODOMC

; Title + Version are included in Title and used in #IfWinActive hotkeys and WinActivate
Title=Lintalist
Version=1.9.15
Version=1.9.16

; Gosub, ReadPluginSettings

Expand Down Expand Up @@ -214,7 +214,7 @@ If (ScriptPaused = 1)
Menu, tray, Check, Pause &Scripts
; /Tray Menu

; Dynamic Gui elements, postions etc.
; Dynamic Gui elements, positions etc.
Gosub, GuiStartupSettings
; /Dynamic Gui settings

Expand Down Expand Up @@ -250,7 +250,7 @@ If (StartSearchHotkey = "Capslock")
MsgBox, 64, Lintalist, %A_LoopField% is running may conflict with Capslock.`nChange the Lintalist Hotkey in the Configuration.`nLook for the StartSearchHotkey setting.`n`nYou can find the Configuration option in the tray menu or`nvia the Edit, Configuration menu in the Lintalist search window.
}

; check capslock and scrolllock status so we can actually use them as hotkey if defined by user and
; check capslock and ScrollLock status so we can actually use them as hotkey if defined by user and
; they are already in the DOWN (active) state when Lintalist is started

ProgramHotKeyList:="StartSearchHotkey,StartOmniSearchHotkey,QuickSearchHotkey,ExitProgramHotKey"
Expand Down Expand Up @@ -404,7 +404,7 @@ Gui, 1:Font ; TODO BIGICONS

If !IsNVDARunning
Gui, 1:Add, Custom, ClassToolbarWindow32 hwndhToolbar 0x0800 0x0100 0x0008 0x0040 x%barx% y%Yctrl% w580 ; TODO BIGICONS
else if IsNVDARunning ; skipt tooltips to avoid it being read twice (button name + tooltip)
else if IsNVDARunning ; skip tooltips to avoid it being read twice (button name + tooltip)
Gui, 1:Add, Custom, ClassToolbarWindow32 hwndhToolbar 0x0800 0x0008 0x0040 x%barx% y%Yctrl% w580 ; TODO BIGICONS

Gui, 1:Font,s%fontsize%,%font%
Expand Down Expand Up @@ -554,7 +554,7 @@ Gui, 1:Default
LV_Delete()
GuiControl,1: , Edit2, %A_Space% ; fix preview if no more snippets e.g. ghosting of last snippet

; setup imagelist and define icons
; setup ImageList and define icons
;#Include %A_ScriptDir%\include\ImageList.ahk

If (SubStr(CurrText,1,1) = OmniChar) or (OmniSearch = 1)
Expand Down Expand Up @@ -740,14 +740,14 @@ Clicked:
Return
}

; ignore all other events apart from doubleclick and normal left-click
; ignore all other events apart from DoubleClick and normal left-click
If A_GuiControlEvent not in DoubleClick,Normal
Return
IfEqual A_GuiControlEvent, Normal
{
ShowPreview(PreviewSection)
If (SingleClickSends = 0) ; if set to 1 in configuration a normal click will act
Return ; the same as a doubleclick (also configurable)
Return ; the same as a DoubleClick (also configurable)
}

If (DoubleClickSends = 1)
Expand Down Expand Up @@ -951,22 +951,25 @@ If (Script = "") or (ScriptPaused = 1) ; script is empty so we need to paste Tex
}
}


If !(formatted > 0) ; only check for ^| post if it is a plain text snippet
Clipboard:=CheckCursorPos(Clipboard)
formatted:=0
GUI, 1:Destroy

If Statistics
If Statistics
Stats("TotalBytes",StrLen(Clipboard))

If AltPaste[ActiveWindowProcessName].HasKey("PasteMethod")
SnippetPasteMethod:=AltPaste[ActiveWindowProcessName].PasteMethod

If (SnippetPasteMethod = 0) or (SnippetPasteMethod = "") ; there was no PasteMethod plugin in the snippet
{

If (PasteMethod = 0) ; paste it and clear formatted clipboard
If (PasteMethod = 0) or (SnippetPasteMethod = 0) ; paste it and clear formatted clipboard
{
SendKey(SendMethod, ShortcutPaste)
PlaySound(PlaySound,"paste")
Clipboard:=ClipSet("s",2,SendMethod,Clip) ; Must be 2 to restore clipboard #217
WinClip.Clear()
}
else If (PasteMethod = 1) ; paste it, keep formatted clipboard
Expand All @@ -975,15 +978,15 @@ If (Script = "") or (ScriptPaused = 1) ; script is empty so we need to paste Tex
PlaySound(PlaySound,"paste")
}
}
else ; PasteMethod was set in the snippet
else ; PasteMethod was set in the snippet or in AltPaste.ini
If (SnippetPasteMethod = 1) ; 1 Paste snippet and keep it as the current clipboard content (so you can manually paste it again)
{
SendKey(SendMethod, ShortcutPaste)
PlaySound(PlaySound,"paste")
}
; else PasteMethod was set in the snippet, so it must be: 2 Don't paste snippet content but copy it to the clipboard so you can manually paste it.

If (((BackLeft > 0) or (BackUp > 0)) and (PasteMethod <> 2)) ; place caret at postion defined in snippet text via ^|
If (((BackLeft > 0) or (BackUp > 0)) and (PasteMethod <> 2)) ; place caret at position defined in snippet text via ^|
{
If (BackUp > 0)
{
Expand Down Expand Up @@ -2032,7 +2035,7 @@ Gui, 10:Submit,NoHide
If (item = "") ; if we didn't focus on results list while "typing to filter" in Choice it may return empty
{
ControlGet, item, List, Focused, ListBox1, Select and press enter
If InStr(item,"`n") ; we may get all the results of the "typing to filter" so asume we want first result
If InStr(item,"`n") ; we may get all the results of the "typing to filter" so assume we want first result
item:=Trim(StrSplit(item,"`n").1,"`n`r")
}
Gosub, 10GuiSavePos
Expand Down Expand Up @@ -2520,7 +2523,7 @@ If InStr(clip,"[[A_") ; check for built-in variables - https://autohotkey.com/do
PluginProcessFunction:=ProcessFunction(PluginName,PluginOptions)
if (clipsave = clip) ; if function hasn't modified the clip, modify clip by replacing the function calls
clip:=StrReplace(clip,PluginText,PluginProcessFunction)
if InStr(clip,PluginText) ; safety check, if func HAS modified the clip, but has omitted to remove itself from clip we need to remove it otherwise we're stuk in an endless loop
if InStr(clip,PluginText) ; safety check, if func HAS modified the clip, but has omitted to remove itself from clip we need to remove it otherwise we're stuck in an endless loop
clip:=StrReplace(clip,PluginText)
clipsave:="", PluginProcessFunction:=""
}
Expand Down Expand Up @@ -2917,7 +2920,7 @@ if !cl_ReadOnly

; this same code is also in ReadIni.ahk
; just make sure these specific settings have a value so reloading/restarting works better
; (when updateing AHK via the official installer script it seems some settings are lost)
; (when updating AHK via the official installer script it seems some settings are lost)
IniListFinalCheck:="Lock,Case,ShorthandPaused,ShortcutPaused,ScriptPaused"
Loop, parse, IniListFinalCheck, CSV
If %A_LoopField% is not number
Expand Down
2 changes: 1 addition & 1 deletion version.ini
@@ -1,5 +1,5 @@
[settings]
version=1.9.15
version=1.9.16
auto=1
beta=0
; auto = 1 - automatic update possible, set to 0 to alert user to read the release notes
Expand Down

0 comments on commit 21a692e

Please sign in to comment.