From c9fd44766e4457e61369d45c8ba060caa1640f8b Mon Sep 17 00:00:00 2001 From: hi5 Date: Wed, 5 Jul 2023 12:16:23 +0200 Subject: [PATCH] v1.108 timestamp related updates --- changelog.md | 11 ++++++++- cl3.ahk | 58 +++++++++++++++++++++++++++++++++++----------- lib/settings.ahk | 18 ++++++++++++-- plugins/search.ahk | 20 ++++++++++++++-- readme.md | 2 +- 5 files changed, 89 insertions(+), 20 deletions(-) diff --git a/changelog.md b/changelog.md index 587b71f..b71d572 100644 --- a/changelog.md +++ b/changelog.md @@ -1,10 +1,19 @@ # Changelog +### v1.108 + +* New: also show timestamp in tooltip (cycle forward, backward, plugin) and search. +* New: also show number of lines in search results (number only) +* Change: timestamp now has two parts, separated by a pipe character (|) + first part (before |): either a character, default @, or a number, for example 128336 for Unicode clock character 🕐 + second part (after |): time format options - see v1.107 +* Change: when cycling back past "z" show number in tooltip instead of character that no longer had any relation to "menu order" + ### v1.107 * New: Option to show timestamp in clipboard history menu - https://github.com/hi5/CL3/issues/23 See https://www.autohotkey.com/docs/v1/lib/FormatTime.htm#Time_Formats for options (e.g. HH:mm (24hr) or hh:mm tt (12hr AM/PM)) -* Fix: Open Template folder - now use commander_path env. variable/registry combined with WinGet ProcessPath/ProcessName, so it should now work with running 32/64 versions. Starts 32bit by default if TC is not running but can be detected. +* Fix: Open Template folder - now use commander_path environment variable/registry combined with WinGet ProcessPath/ProcessName, so it should now work with running 32/64 versions. Starts 32bit by default if TC is not running but can be detected. * Fix: Use MenuWidth setting in DispMenuText() function to check length instead of previously hardcoded value of 60 ### v1.106 diff --git a/cl3.ahk b/cl3.ahk index e75d8e4..b93b490 100644 --- a/cl3.ahk +++ b/cl3.ahk @@ -1,10 +1,12 @@ /* -Script : CL3 ( = CLCL CLone ) - AutoHotkey 1.1+ (Ansi and Unicode) -Version : 1.107 +Script : CL3 ( = CLCL CLone ) - AutoHotkey 1.1+ +Version : 1.108 Author : hi5 -Purpose : A lightweight clone of the CLCL clipboard caching utility which can be found at - http://www.nakka.com/soft/clcl/index_eng.html written in AutoHotkey +Purpose : CL3 started as a lightweight clone of the CLCL clipboard caching utility + which can be found at http://www.nakka.com/soft/clcl/index_eng.html. + But some unique features have been added making it more versatile + "text only" Clipboard manager. Source : https://github.com/hi5/CL3 Features: @@ -40,7 +42,7 @@ SetWorkingDir, %A_ScriptDir% AutoTrim, off StringCaseSense, On name:="CL3 " -version:="v1.107" +version:="v1.108" CycleFormat:=0 Templates:={} Global CyclePlugins,History,SettingsObj,Slots,ClipChainData ; CyclePlugins v1.72+, others v1.9.4 for API access @@ -58,7 +60,7 @@ loop, parse, iconlist, CSV icon%A_LoopField%:="icon-" A_LoopField ".ico" ; -;@Ahk2Exe-SetFileVersion 1.107 +;@Ahk2Exe-SetFileVersion 1.108 ;@Ahk2Exe-SetDescription CL3 ;@Ahk2Exe-SetCopyright MIT License - (c) https://github.com/hi5 ; @@ -303,7 +305,13 @@ While GetKeyState(hk_cyclemodkey,"D") and cyclebackward If (ClipCycleCounter = 1) and (ClipboardPrivate = 1) Indicator:="*" If (ClipCycleCounter <> 0) - ttext:=% Chr(96+ClipCycleCounter) Indicator " : " DispToolTipText(History[ClipCycleCounter].text) + { + If (ClipCycleCounter < 27) + ClipCycleCounterIndicator:=Chr(96+ClipCycleCounter) + Else + ClipCycleCounterIndicator:=ClipCycleCounter + ttext:=% ClipCycleCounterIndicator Indicator " : " DispToolTipText(History[ClipCycleCounter].text,,History[ClipCycleCounter].time) + } else ttext:="[cancelled]" If (oldttext <> ttext) @@ -352,8 +360,12 @@ While GetKeyState(hk_cyclemodkey,"D") and cycleforward Indicator:="" If (ClipCycleCounter = 1) and (ClipboardPrivate = 1) Indicator:="*" + If (ClipCycleCounter < 27) + ClipCycleCounterIndicator:=Chr(96+ClipCycleCounter) + Else + ClipCycleCounterIndicator:=ClipCycleCounter If (ClipCycleCounter <> 0) - ttext:=% Chr(96+ClipCycleCounter) Indicator " : " DispToolTipText(History[ClipCycleCounter].text) + ttext:=% ClipCycleCounterIndicator Indicator " : " DispToolTipText(History[ClipCycleCounter].text,,History[ClipCycleCounter].time) else ttext:="[cancelled]" If (oldttext <> ttext) @@ -397,8 +409,17 @@ If (ClipCycleCounter = 0) or (ClipCycleCounter = "") ClipCycleCounter:=1 While GetKeyState(hk_cyclemodkey,"D") { + If ShowTime + { + time:=History[ClipCycleCounter].time + If TimeFormat and time + { + FormatTime, disptime, %time%, %TimeFormatTime% + disptime := Ltrim(TimeFormatIndicator) disptime " " + } + } If (ClipCycleCounter <> 0) - ttext:=% "Plugin: " ((CyclePlugins.HasKey(CycleFormat) = "0") ? "[none]" : CyclePlugins[CycleFormat]) CyclePluginsToolTipLine DispToolTipText(History[ClipCycleCounter].text,CycleFormat) + ttext:=% disptime "Plugin: " ((CyclePlugins.HasKey(CycleFormat) = "0") ? "[none]" : CyclePlugins[CycleFormat]) CyclePluginsToolTipLine DispToolTipText(History[ClipCycleCounter].text,CycleFormat) else ttext:="Plugin: [cancelled]" CyclePluginsToolTipLine If (oldttext <> ttext) @@ -406,7 +427,7 @@ While GetKeyState(hk_cyclemodkey,"D") ToolTip, % ttext, %A_CaretX%, %A_CaretY% oldttext:=ttext } - + disptime:="",time:="" Sleep 100 KeyWait, %hk_cycleplugins% ; This prevents the keyboard's auto-repeat feature from interfering. } @@ -648,7 +669,7 @@ Return DispMenuText(TextIn,lines="1",time="") { - global MenuWidth,ShowLines,LineTextFormat,ShowTime,TimeFormat + global MenuWidth,ShowLines,LineTextFormat,ShowTime,TimeFormat,TimeFormatIndicator,TimeFormatTime If (lines=1) linetext:=LineTextFormat[1] @@ -676,22 +697,31 @@ DispMenuText(TextIn,lines="1",time="") disptime:="" If TimeFormat and Time { - FormatTime, disptime, %time%, %TimeFormat% - TextOut .= " " Chr(128336) " " disptime + FormatTime, disptime, %time%, %TimeFormatTime% + TextOut .= TimeFormatIndicator disptime } } Return LTRIM(TextOut," `t") } -DispToolTipText(TextIn,Format=0) +DispToolTipText(TextIn,Format=0,time=0) { + Global ShowTime, TimeFormat, TimeFormatIndicator, TimeFormatTime TextOut:=RegExReplace(TextIn,"^\s*") TextOut:=SubStr(TextOut,1,750) ;StringReplace,TextOut,TextOut,`;,``;,All FormatFunc:=StrReplace(CyclePlugins[Format]," ") If IsFunc(FormatFunc) TextOut:=%FormatFunc%(TextOut) + If ShowTime + { + If TimeFormat and Time + { + FormatTime, disptime, %time%, %TimeFormatTime% + TextOut := Ltrim(TimeFormatIndicator) disptime "`n" TextOut + } + } Return TextOut } diff --git a/lib/settings.ahk b/lib/settings.ahk index 002cb63..ce33d7f 100644 --- a/lib/settings.ahk +++ b/lib/settings.ahk @@ -34,7 +34,7 @@ Settings() IniRead, BackupTimer , %ini%, settings, BackupTimer, 10 IniRead, Exclude , %ini%, settings, Exclude, 0 IniRead, LineFormat , %ini%, settings, LineFormat, \t(\l line),\t(\l lines) - IniRead, TimeFormat , %ini%, settings, TimeFormat, HH:mm + IniRead, TimeFormat , %ini%, settings, TimeFormat, @|HH:mm IniRead, SettingsFolders , %ini%, settings, SettingsFolders, 0 IniRead, ShowSpecial , %ini%, settings, ShowSpecial , 1 IniRead, ShowTemplates , %ini%, settings, ShowTemplates, 1 @@ -58,6 +58,20 @@ Settings() folders:=StrReplace(folders,"%A_" Trim(A_LoopField," ") "%", %tmpfolder%) } + If InStr(TimeFormat,"|") + { + TimeFormatIndicator:=StrSplit(TimeFormat,"|").1 + If TimeFormatIndicator is number + TimeFormatIndicator:=Chr(TimeFormatIndicator) + TimeFormatIndicator:=A_Space TimeFormatIndicator A_Space + TimeFormatTime:=StrSplit(TimeFormat,"|").2 + } + Else + { + TimeFormatIndicator:="" + TimeFormatTime:=TimeFormat + } + ClipDataFolder:=StrSplit(folders,";").1 "\ClipData\" If (ClipDataFolder = "\ClipData\") ClipDataFolder:=A_ScriptDir "\ClipData\" @@ -137,7 +151,7 @@ Settings_Default() , ShowMorehistory : 1 , ShowExit : 1 , Exclude : "" - , TimeFormat : "HH:mm" + , TimeFormat : "@|HH:mm" , LineFormat : "\t(\l line),\t(\l lines)" } } diff --git a/plugins/search.ahk b/plugins/search.ahk index 309b610..a51d41e 100644 --- a/plugins/search.ahk +++ b/plugins/search.ahk @@ -34,9 +34,22 @@ StartList:="" for k, v in History { add:=v.text + time:=v.time + if ShowLines + linetext:=" - " v.lines + else + linetext:="" + + disptime:="" stringreplace, add, add, |,,All stringreplace, add, add, `n,%A_Space%,All - StartList .= "[" SubStr("00" A_Index,-2) "] " Add "|" + If ShowTime + If TimeFormat and Time + { + FormatTime, disptime, %time%, %TimeFormatTime% + disptime := Ltrim(TimeFormatIndicator) disptime " " + } + StartList .= disptime "[" SubStr("00" A_Index,-2) linetext "] " Add "|" } Gui, Search:Destroy @@ -81,7 +94,10 @@ if (Choice = "") { ControlGet, Choice, list, , ListBox1, A } -id:=Ltrim(SubStr(Choice,2,InStr(Choice,"]")-2),"0") +; id:=Ltrim(SubStr(Choice,2,InStr(Choice,"]")-2),"0") +RegExMatch(Choice,"\[0*(\d+)",id) +Id:=id1 +id1:="" if (id = "") id:=1 ClipText:=History[id].text diff --git a/readme.md b/readme.md index 71a4c85..b1bde5e 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# CL3 v1.107 - Clipboard caching utility +# CL3 v1.108 - Clipboard caching utility CL3 started as a lightweight clone of the CLCL clipboard caching utility which can be found at .