- Offizieller Beitrag
EDIT 2023-10-23
Neue Einzel- Variante "DebugAU3.lua"
Ich hatte das Prinzip der kaskadierenden Hotkeys bereits hier gepostet. In dieser Variante war es aber recht unflexibel und auch recht aufwändig zu installieren.
Jetzt habe ich das als AddOn, basierend auf .properties, erstellt. So lassen sich Änderungen ganz einfach in der Properties-Datei einpflegen. (Die ownhotkeys.properties ist, wie alle anderen Properties-Dateien, über das Menü "Optionen" in SciTE erreichbar).
Damit eine eigene Properties-Datei auch nutzbar ist, muss man entsprechende Einträge vornehmen. Wer das gern per Hand machen möchte, kann die manuelle Installation verwenden. Wer es bequemer mag, nutzt den Installer. Dateien, an denen Änderungen vorgenommen werden, werden vorher gesichert. Sollte die Sicherung fehlschlagen, bricht die Installation ab.
Die Installation muss aus SciTE heraus gestartet werden. (OHK_Installer.au3 im entpackten Ordner ausführen)
Zur Funktionsweise zitiere ich mal aus meinem o.a. Thread
ZitatSciTE hat ja bereits alle Sequenzen von Ctrl+Key vorbelegt. Das ist natürlich unschön, da man für eigene Hotkeys dann auf umständliche Kombinationen zurückgreifen muss, die einem fast die Finger brechen. Oder man muss die voreingestellten Hotkeys ummappen.
Aber das hat ein Ende. Die Lösung: Cascading Hotkeys
Das funktioniert recht simpel. Ich habe mir als Trigger die Sequenz "Ctrl+Win" ausgewählt. Das beißt sich mit keinem anderen Hotkey und läßt sich schön mit 2 Fingern einer Hand erledigen. Ist dieser Hotkey gedrückt, läßt man die Win-Taste wieder los aber hält die Ctrl-Taste weiterhin gedrückt und wählt nun die beliebige Taste für die zweite Ctrl+Key-Sequenz. Somit ergeben sich Hotkeys der Form: "Ctrl+Win, Ctrl+X" oder "Ctrl+Win, Ctrl+F2" usw..
In der vorigen Variante gab es das Problem, dass sich keine au3-Skripte starten liessen. Um das zu ermöglichen wird jetzt die "shell.dll" (von SciTE-RU) verwendet.
Es werden einige Funktionen mitgeliefert, die ihr im Installer den Hotkeys zuordnen könnt (oder auch jederzeit später in der Properties-Datei).
Hier eine Liste der Funktionen
• AddFuncName
Fügt hinter "EndFunc" einer jeden im aktuellen Skript erstellten Funktion hinzu: " ;==> Function_Name"
• AlignAtEqualSign
Richtet die markierten Zeilen am ersten, weitesten rechts befindlichen Gleichheitszeichen aus
• DebugToConsole
Debug der Variable unter dem Cursor mit/ohne @error, @extended (Tabellenstil), auch Array-Vars mit Index
• ExecuteAU3
Führt eine au3-Datei mit/ohne Parameter aus
• GetHotkeyList
Schreibt eine Auflistung der genutzten Hotkeys in die Konsole
• GoToLine [hard coded]
Geht zur nächsten/vorigen Zeile, setzt den Cursor ans Zeilenende
• ReloadStartupLua
Neuladen des Lua Startup Skriptes
• Repeat
Wiederholt das Zeichen links vom Cursor n-mal
Das Zeichen schreiben, den Repeat-Modus aktivieren, Ziffern für "n" eingeben,
<ENTER> schreibt das Zeichen n-mal (Zähler beinhaltet das erste Zeichen)
• RunSelectedCode
Führt markierten Code in einer temporären Datei aus.
• SelectionMoveH [hard coded]
Verschiebt markierten Text in der Zeile nach links/rechts.
• SelectionMoveV [hard coded]
Verschiebt markierten Text zwischen den Zeilen auf/ab.
• SelectLine
Markiert die gesamte Zeile des Cursors.
• SelectTextInLine
Markiert die gesamte Zeile des Cursors ohne führende Leerzeichen/Tabs.
• SetSelection
Markiert das Wort unter dem Cursor mit/ohne führendem "$" / mit folgenden eckigen Klammern
• SkipToComment
Setzt den Cursor an den Kommentaranfang der Zeile, sofern vorhanden.
• ToggleAdjacentChars
Tauscht benachbarte Zeichen
Alles anzeigen
Gerade die Funktionen zum Text/Zeilen verschieben möchte ich nicht mehr missen.
Wenn ihr alle vordefinierten Hotkeys nutzt, sind dieses 65 :D. Das kann man aber gern noch um Hotkeys in Kombination mit ", . _ etc." erweitern, falls mal Bedarf besteht.
!! DEMO ANGUCKEN !!
Ein Hinweis noch:
Mit "OHK.ExecuteAU3()" lassen sich AutoIt-Skripte ausführen. Sofern diese Skripte eine Konsolenausgabe enthalten (ConsoleWrite) muss diese Ausgabe vom aufrufenden Lua-Skript an die SciTE-Output-Pane übergeben werden. Dazu habe ich die "SciTE_Output.au3" beigefügt, die vom Installer in euren User-Include-Ordner kopiert wird. In den betreffenden AU3-Skripten muss dann nur der Funktionsname "ConsoleWrite" durch "_SciTE_Output" ersetzt werden und "#Include <SciTE_Output.au3>" eingefügt werden.
Edit: 29.10.2013
Zur Ergänzung noch die Funktion "OHK.ShellExecute()". Mit ihr lassen sich dann exe-Dateien und beliebige Dateien mit ihrem verknüpften Programm aufrufen.
Werde es später noch in die Dateien einbetten, hier schonmal die Funktion (einfach in die OHKFuncs.lua reinkopieren)
Spoiler anzeigen
-------------------------------------------------------------------------
--[[ OHK.ShellExecute( path_file [, param1 [, param2 [, ..] ] ] )
]]
-------------------------------------------------------------------------
OHK.ShellExecute = function(_path, ...)
local tParam = {_path, ...}
local sCmd = '"'.._path..'"'
if #tParam > 1 then for i = 2, #tParam do
sCmd = sCmd..' "'..tParam[i]..'"'
end end
shell.exec(sCmd)
end --> ShellExecute
-------------------------------------------------------------------------
Alles anzeigen
autoit.de/wcf/attachment/23022/
Manuelle Installation
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# #
# O W N H O T K E Y S S E T T I N G S #
# #
# #
# Installation manually: #
# #
# • copy "ownhotkeys.template.properties" as "ownhotkeys.properties" into folder: #
# ..\USER-DIRECTORY\ #
# • in file SciTEUser.properties: #
# add line: import ownhotkeys #
# • copy "shell.dll" in the folder with your Lua scripts #
# (own folder, i.e. inside USER-DIR recommended) #
# shell.dll is needed to call au3-files. #
# • be sure, that your Lua script path is added to package.cpath in SciTEStartup.lua #
# Recommended way: #
# - create own property for your Lua script path in SciTEUser.properties #
# Lua.User.Scripts.Path=C:\YOUR\PATH\LUA\SCRIPTS #
# - use a global Lua variable LUA_USER_PATH and add it to your SciTEStartup.lua as below #
# (position: top of script) #
# #
# local sUserLua = props["Lua.User.Scripts.Path"] .. "" #
# LUA_USER_PATH = sUserLua .. "\\?.dll;" .. sUserLua .. "\\?\\?.dll;" #
# LUA_USER_PATH = LUA_USER_PATH .. sUserLua .. "\\?.lua;" .. sUserLua .. "\\?\\?.lua;" #
# ------------------------------------------------------------------------------------ #
# package.cpath = LUA_USER_PATH..package.cpath #
# #
# So you can store dll files (and Lua files too) as: #
# ..\own_folder\name.dll or #
# ..\own_folder\name\name.dll #
# with access to this from any script. #
# • copy "OHKfuncs.lua" and "Ownhotkeys.lua" in your own Lua scripts folder #
# • copy "SciTE_Output.au3" to your user include folder #
# Its requiered to send output from called au3-files to SciTE. Replace "ConsoleWrite()" #
# with "_SciTE_Output()" in related au3-files and include "SciTE_Output.au3" there. #
# • insert function to load user files in SciTEStartup.lua (behind function LoadLuaFile): #
# #
# function LoadUserLuaFile(file) #
# LoadLuaFile(file, props["Lua.User.Scripts.Path"] .. "") #
# end -- LoadUserLuaFile() #
# #
# • add at the end of SciTEStartup.lua #
# LoadUserLuaFile("Ownhotkeys.lua") #
# • now set the properties (indicator-key, caret settings, using hardcoded hotkeys, #
# Lua script path, hotkeys) #
# • Restart SciTE and use your hotkeys. You can open the propertiy file anytime about #
# menu: Options. #
# #
# Using Own Hotkeys: #
# • hit Ctrl + Indicator-key #
# • hold pressed the Ctrl-key #
# • release Indicator-key only #
# • hit second key from your sequence #
# #
# Write commands for hotkeys as: #
# Use commands without quotation marks! #
# • "[script.lua] function_lua(param)" from this script #
# • "C:\path\script.lua function_lua(param)" from this script #
# if script.lua has no path --> encapsulate the script.lua in square braces, #
# the path of the own.mode.func.path property is used than. #
# • lua-commands as string (it's possible to insert full scripts here) #
# example (inserts a small Lua function header): #
# own.mode.cmd.xx=if props['FileExt']:upper() == 'LUA' then \ #
# editor:InsertText(editor.CurrentPos, ('-'):rep(100) .. \ #
# '\n--[[ \nin...:\t\nout..:\t\n]]\n'..('-'):rep(100)..'\n\n'..('-'):rep(100)) end #
# • "dofile ('C:\\full-path\\file.lua')" #
# • to break command-lines use " " at the end of text, line is connected during scanning. #
# • own.mode.descript.xx includes the key sequence. Add "|Your-Description" behind this. #
# #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
Alles anzeigen
Edit 15.11.2016
Nach langem mal eine kleine Anpassung, die ihr bitte selbst in die Datei einpflegt:
Da ich es bisher nie verwendet hatte, war mir nicht aufgefallen, dass bei Nutzung der SciTE-Variablen ( $(FilePath) etc. ) als Parameter in Befehlszeilen, Backslash nicht escaped werden. Deshalb habe ich nun eine Makrofunktion erstellt, die mit identischen Namen wie die SciTE-Variablen funktioniert, aber (wie in AutoIt) durch @ gekennzeichnet werden ( "$(FilePath)" = "@FilePath", "$(FileDir)"="@FileDir", usw. ).
-- Vor der ersten Funktionsdeklaration in die OHKfuncs.lua einfügen:
-------------------------------------------------------------------------
local scitemacro = function(_value)
local tMacro = {
['@FilePath'] = props['FilePath'], -- full path of the current file
['@FileDir'] = props['FileDir'], -- directory of the current file without a trailing slash
['@FileName'] = props['FileName'], -- base name of the current file
['@FileExt'] = props['FileExt'], -- extension of the current file
['@FileNameExt'] = props['FileNameExt'], -- '@FileName'.'@FileExt'
['@Language'] = props['Language'], -- name of the lexer used for the current file
['@SessionPath'] = props['SessionPath'], -- full path of the current session
['@CurrentSelection'] = props['CurrentSelection'], -- value of the currently selected text
['@CurrentWord'] = props['CurrentWord'], -- value of word which the caret is within or near
['@Replacements'] = props['Replacements'], -- number of replacements made by last Replace command
['@SelectionStartColumn'] = props['SelectionStartColumn'], -- column where selection starts
['@SelectionStartLine'] = props['SelectionStartLine'], -- line where selection starts
['@SelectionEndColumn'] = props['SelectionEndColumn'], -- column where selection ends
['@SelectionEndLine'] = props['SelectionEndLine'], -- line where selection ends
['@CurrentMessage'] = props['CurrentMessage'], -- most recently selected output pane message
['@SciteDefaultHome'] = props['SciteDefaultHome'], -- directory in which the Global Options file is found
['@SciteUserHome'] = props['SciteUserHome'], -- directory in which the User Options file is found
['@SciteDirectoryHome'] = props['SciteDirectoryHome'], -- directory in which the Directory Options file is found
['@APIPath'] = props['APIPath'], -- list of full paths of API files from api.filepattern
['@AbbrevPath'] = props['AbbrevPath'], -- full path of abbreviations file
['@ScaleFactor'] = props['ScaleFactor'] -- the screen's scaling factor with a default value of 100
}
return (tMacro[tostring(_value)] or _value)
end
-------------------------------------------------------------------------
-- Die folgenden, geänderten Funktionen in der OHKfuncs.lua ersetzen:
-------------------------------------------------------------------------
--[[ OHK.ExecuteAU3( path_AU3_file [, param1 [, param2 [, ..] ] ] )
]]
-------------------------------------------------------------------------
OHK.ExecuteAU3 = function(_pathAU3, ...)
local tParam = {_pathAU3, ...}
local au3exe = props['autoit3dir']..'\\autoit3.exe'
local sCmd = '"'..au3exe..'" /AutoIt3ExecuteScript "'.._pathAU3..'"'
if #tParam > 1 then for i = 2, #tParam do
sCmd = sCmd..' "'..scitemacro(tParam[i])..'"'
end end
shell.exec(sCmd)
end --> ExecuteAU3
-------------------------------------------------------------------------
-------------------------------------------------------------------------
--[[ OHK.ShellExecute( path_file [, param1 [, param2 [, ..] ] ] )
]]
-------------------------------------------------------------------------
OHK.ShellExecute = function(_path, ...)
local tParam = {_path, ...}
local sCmd = '"'.._path..'"'
if #tParam > 1 then for i = 2, #tParam do
sCmd = sCmd..' "'..scitemacro(tParam[i])..'"'
end end
shell.exec(sCmd)
end --> ShellExecute
-------------------------------------------------------------------------
Alles anzeigen
EDIT 08.07.2019
Anpassung der Debugfunktion zur Verwendung in Lua-Skripten
In der Datei OHKfuncs.lua die Funktion OHK.DebugToConsole mit der folgenden Version ersetzen:
-------------------------------------------------------------------------
--[[ DebugToConsole() --> also recognizes array variables like (*.au3): $a[$i][0], (*.lua): a.b.c[k][v]
• debugs variable under cursor, no error output
DebugToConsole(true) --> *.au3 only
• debugs variable under cursor, error output
DebugToConsole(true, true) --> *.au3 only
• debugs variable under cursor, error & extended output
]]
-------------------------------------------------------------------------
OHK.DebugToConsole = function(_fErr, _fExt)
if props['FileExt']:upper() == 'AU3' then
local sErr = ''
if _fErr then
sErr = ' & "!@ " & @TAB & "#Error: " & @error'
if _fExt then sErr = sErr..' & @TAB & "#Extended: " & @extended' end
sErr = sErr..' & @LF'
end
local caret, sDebug = OHK.SetSelection(false, true)
if sDebug ~= '' then
local s, line = editor:GetSelText(), editor:LineFromPosition(caret) +1
editor:LineEnd()
local sVar = sDebug
if sDebug:find('%[') then sVar = sDebug:gsub('%[', '%['..'" & '):gsub('%]', ' & "'..'%]') end
editor:InsertText(editor.CurrentPos, '\nConsoleWrite("@@_Debug_line" & @TAB & @TAB & @ScriptLineNumber & " var: '..sVar..' --> " & '..sDebug..' & @LF'..sErr..')')
end
editor:SetSel(caret, caret)
elseif props['FileExt']:upper() == 'LUA' then
local function getEndPos(_i)
local caret = _i or editor.CurrentPos
local varstart = editor:WordStartPosition(caret, true)
local varend = editor:WordEndPosition(caret, true)
if editor:textrange(varend, varend +1) == '.' then
varend = getEndPos(varend +1)
end
if editor:textrange(varend, varend +1) == '[' then
local linenum = editor:LineFromPosition(caret)
local linestart = editor:PositionFromLine(linenum)
local linetext, column = editor:GetCurLine()
for s1, e1 in linetext:gmatch('()%b[]()') do
if s1 >= column then varend = linestart + e1 -1 end
end
end
return varend
end
local pos = editor.CurrentPos
local s, e = editor:WordStartPosition(pos, true), getEndPos()
editor:SetSel(s, e)
local sDebug = editor:GetSelText()
local sVar = sDebug
if sDebug:find('%[') then sVar = sDebug:gsub('%[', '%['..'"..'):gsub('%]', '.."'..'%]') end
editor:LineEnd()
editor:InsertText(editor.CurrentPos, '\nprint("@@_Debug_line\t\t"..debug.getinfo(1).currentline.." '..sVar..':", '.. sDebug..')')
editor:SetSel(pos, pos)
end
end --> DebugToConsole
-------------------------------------------------------------------------
Alles anzeigen