From ca857373c39788ab33bfbc74d00099a55e51148f Mon Sep 17 00:00:00 2001 From: Merlijn Wajer Date: Fri, 15 Apr 2011 18:15:30 +0200 Subject: [PATCH] Simba: More keybindings on Linux. Ctrl+Alt+R = Start script Ctrl+Alt+S = Stop script Ctrl+Alt+P = Pick Colour --- Projects/Simba/simbaunit.pas | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Projects/Simba/simbaunit.pas b/Projects/Simba/simbaunit.pas index b65cd33..67bc0aa 100644 --- a/Projects/Simba/simbaunit.pas +++ b/Projects/Simba/simbaunit.pas @@ -50,11 +50,11 @@ uses lcltype, ActnList, SynExportHTML, SynEditKeyCmds, SynEditHighlighter, SynEditMarkupHighAll, LMessages, Buttons, - mmisc, stringutil,mufasatypesutil, mufasabase, v_ideCodeParser, + mmisc, stringutil,mufasatypesutil, mufasabase, about, framefunctionlist, ocr, updateform, Simbasettings, psextension, virtualextension, extensionmanager, settingssandbox, - v_ideCodeInsight, CastaliaPasLexTypes, // Code completion units + v_ideCodeParser, v_ideCodeInsight, CastaliaPasLexTypes, // Code completion units CastaliaSimplePasPar, v_AutoCompleteForm, // Code completion units PSDump, @@ -68,7 +68,13 @@ const interp_CP = 2; //CPascal { Place the shortcuts here } - shortcut_StopScript = 'S'; + {$IFDEF LINUX} + shortcut_StartScript = 'R'; + shortcut_StopScript = 'S'; + shortcut_PickColour = 'P'; + {$ELSE} + // Windows shortcuts here + {$ENDIF} type @@ -591,7 +597,15 @@ end; { Used for global callbacks on LINUX } procedure keybinder_callback(keystring: PChar; user_data: PtrUInt); cdecl; begin - SimbaForm.ActionStopScript.Execute; + writeln('Keystring: ' + keystring); + if keystring = shortcut_StartScript then + SimbaForm.ActionRunScript.Execute + else if keystring = shortcut_StopScript then + SimbaForm.ActionStopScript.Execute + else if keystring = shortcut_PickColour then + SimbaForm.ButtonPickClick(nil) + else + writeln('Unknown keystring: ', keystring) end; { XXX, TODO: Pressing the stop shortcut twice (quickly) may crash Simba. } @@ -600,13 +614,19 @@ begin keybinder_init(); { Initialise keybinder } { Bind keys } + if not keybinder_bind(PChar(shortcut_StartScript), @keybinder_callback, PtrUInt(0)) then + mDebugLn('Unable to register '+ shortcut_StartScript + ' as global hotkey'); if not keybinder_bind(PChar(shortcut_StopScript), @keybinder_callback, PtrUInt(0)) then - mDebugLn('Unable to register Ctrl + Alt + S as global hotkey'); + mDebugLn('Unable to register '+ shortcut_StopScript + ' as global hotkey'); + if not keybinder_bind(PChar(shortcut_PickColour), @keybinder_callback, PtrUInt(0)) then + mDebugLn('Unable to register '+ shortcut_PickColour + ' as global hotkey'); end; procedure Unbind_Linux_Keys; begin + keybinder_unbind(PChar(shortcut_StartScript), @keybinder_callback, PtrUInt(0)); keybinder_unbind(PChar(shortcut_StopScript), @keybinder_callback, PtrUInt(0)); + keybinder_unbind(PChar(shortcut_PickColour), @keybinder_callback, PtrUInt(0)); end; {$ENDIF}