Browse Source

+ Added ability to use ctrl+x,ctrl+c,ctrl+v for clipboard. Enabled by
default on Unix platforms because normal shift+ins is not available in
a lot of terminal emulators. Currently only configurable through
INI-file. UI will follow.

git-svn-id: trunk@2428 -

daniel 19 years ago
parent
commit
0312337a13
6 changed files with 102 additions and 17 deletions
  1. 3 0
      ide/fp.pas
  2. 49 4
      ide/fpide.pas
  3. 17 1
      ide/fpini.pas
  4. 13 8
      ide/fpstre.inc
  5. 16 0
      ide/fpvars.pas
  6. 4 4
      ide/fpviews.pas

+ 3 - 0
ide/fp.pas

@@ -346,6 +346,9 @@ BEGIN
   InitDesktopFile;
   InitDesktopFile;
   LoadDesktop;
   LoadDesktop;
 
 
+  {Menubar might be changed because of loading INI file.}
+  IDEapp.reload_menubar;
+
   { Handle Standard Units }
   { Handle Standard Units }
   if UseAllUnitsInCodeComplete then
   if UseAllUnitsInCodeComplete then
     AddAvailableUnitsToCodeComplete(false);
     AddAvailableUnitsToCodeComplete(false);

+ 49 - 4
ide/fpide.pas

@@ -32,6 +32,7 @@ type
       constructor Init;
       constructor Init;
       procedure   InitDesktop; virtual;
       procedure   InitDesktop; virtual;
       procedure   InitMenuBar; virtual;
       procedure   InitMenuBar; virtual;
+      procedure   reload_menubar;
       procedure   InitStatusLine; virtual;
       procedure   InitStatusLine; virtual;
       procedure   Open(FileName: string;FileDir:string);
       procedure   Open(FileName: string;FileDir:string);
       function    OpenSearch(FileName: string) : boolean;
       function    OpenSearch(FileName: string) : boolean;
@@ -154,6 +155,15 @@ procedure PutCommand(TargetView: PView; What, Command: Word; InfoPtr: Pointer);
 var
 var
   IDEApp: TIDEApp;
   IDEApp: TIDEApp;
 
 
+{Configurable keys.}
+const menu_key_edit_cut:string[63]=menu_key_edit_cut_borland;
+      menu_key_edit_copy:string[63]=menu_key_edit_copy_borland;
+      menu_key_edit_paste:string[63]=menu_key_edit_paste_borland;
+      menu_key_hlplocal_copy:string[63]=menu_key_hlplocal_copy_borland;
+      cut_key:word=kbShiftDel;
+      copy_key:word=kbCtrlIns;
+      paste_key:word=kbShiftIns;
+
 implementation
 implementation
 
 
 uses
 uses
@@ -293,8 +303,10 @@ begin
 end;
 end;
 
 
 procedure TIDEApp.InitMenuBar;
 procedure TIDEApp.InitMenuBar;
+
 var R: TRect;
 var R: TRect;
     WinPMI : PMenuItem;
     WinPMI : PMenuItem;
+
 begin
 begin
   GetExtent(R); R.B.Y:=R.A.Y+1;
   GetExtent(R); R.B.Y:=R.A.Y+1;
   WinPMI:=nil;
   WinPMI:=nil;
@@ -331,9 +343,9 @@ begin
       NewItem('R~e~do All','', kbNoKey, cmRedoAll, hcRedo,
       NewItem('R~e~do All','', kbNoKey, cmRedoAll, hcRedo,
 {$endif DebugUndo}
 {$endif DebugUndo}
       NewLine(
       NewLine(
-      NewItem(menu_edit_cut,menu_key_edit_cut, kbShiftDel, cmCut, hcCut,
-      NewItem(menu_edit_copy,menu_key_edit_copy, kbCtrlIns, cmCopy, hcCut,
-      NewItem(menu_edit_paste,menu_key_edit_paste, kbShiftIns, cmPaste, hcPaste,
+      NewItem(menu_edit_cut,menu_key_edit_cut, cut_key, cmCut, hcCut,
+      NewItem(menu_edit_copy,menu_key_edit_copy, copy_key, cmCopy, hcCut,
+      NewItem(menu_edit_paste,menu_key_edit_paste, paste_key, cmPaste, hcPaste,
       NewItem(menu_edit_clear,menu_key_edit_clear, kbCtrlDel, cmClear, hcClear,
       NewItem(menu_edit_clear,menu_key_edit_clear, kbCtrlDel, cmClear, hcClear,
       NewItem(menu_edit_selectall,'', kbNoKey, cmSelectAll, hcSelectAll,
       NewItem(menu_edit_selectall,'', kbNoKey, cmSelectAll, hcSelectAll,
       NewItem(menu_edit_unselect,'', kbNoKey, cmUnselect, hcUnselect,
       NewItem(menu_edit_unselect,'', kbNoKey, cmUnselect, hcUnselect,
@@ -479,6 +491,37 @@ begin
   // Update; Desktop is still nil at that point ...
   // Update; Desktop is still nil at that point ...
 end;
 end;
 
 
+procedure Tideapp.reload_menubar;
+
+begin
+   delete(menubar);
+   dispose(menubar,done);
+   case EditKeys of
+     ekm_microsoft:
+       begin
+         menu_key_edit_cut:=menu_key_edit_cut_microsoft;
+         menu_key_edit_copy:=menu_key_edit_copy_microsoft;
+         menu_key_edit_paste:=menu_key_edit_paste_microsoft;
+         menu_key_hlplocal_copy:=menu_key_hlplocal_copy_microsoft;
+         cut_key:=kbCtrlX;
+         copy_key:=kbCtrlC;
+         paste_key:=kbCtrlV;
+       end;
+     ekm_borland:
+       begin
+         menu_key_edit_cut:=menu_key_edit_cut_borland;
+         menu_key_edit_copy:=menu_key_edit_copy_borland;
+         menu_key_edit_paste:=menu_key_edit_paste_borland;
+         menu_key_hlplocal_copy:=menu_key_hlplocal_copy_borland;
+         cut_key:=kbShiftDel;
+         copy_key:=kbCtrlIns;
+         paste_key:=kbShiftIns;
+       end;
+   end;
+   initmenubar;
+   insert(menubar);
+end;
+
 procedure TIDEApp.InitStatusLine;
 procedure TIDEApp.InitStatusLine;
 var
 var
   R: TRect;
   R: TRect;
@@ -1255,4 +1298,6 @@ begin
   DoneHelpSystem;
   DoneHelpSystem;
 end;
 end;
 
 
-END.
+
+
+end.

+ 17 - 1
ide/fpini.pas

@@ -40,7 +40,7 @@ uses
 {$endif USE_EXTERNAL_COMPILER}
 {$endif USE_EXTERNAL_COMPILER}
   WConsts,WUtils,WINI,WViews,WEditor,WCEdit,
   WConsts,WUtils,WINI,WViews,WEditor,WCEdit,
   {$ifndef NODEBUG}FPDebug,{$endif}FPConst,FPVars,
   {$ifndef NODEBUG}FPDebug,{$endif}FPConst,FPVars,
-  FPIntf,FPTools,FPSwitch,FPString;
+  FPIntf,FPTools,FPSwitch,FPString,fpccrc;
 
 
 const
 const
   PrinterDevice : string = 'prn';
   PrinterDevice : string = 'prn';
@@ -69,6 +69,7 @@ const
   secBreakpoint  = 'Breakpoints';
   secBreakpoint  = 'Breakpoints';
   secWatches     = 'Watches';
   secWatches     = 'Watches';
   secHighlight   = 'Highlight';
   secHighlight   = 'Highlight';
+  secKeyboard    = 'Keyboard';
   secMouse       = 'Mouse';
   secMouse       = 'Mouse';
   secSearch      = 'Search';
   secSearch      = 'Search';
   secTools       = 'Tools';
   secTools       = 'Tools';
@@ -127,6 +128,7 @@ const
   ieDesktopFlags     = 'DesktopFileFlags';
   ieDesktopFlags     = 'DesktopFileFlags';
   ieCenterDebuggerRow= 'CenterCurrentLineWhileDebugging';
   ieCenterDebuggerRow= 'CenterCurrentLineWhileDebugging';
   ieShowReadme       = 'ShowReadme';
   ieShowReadme       = 'ShowReadme';
+  ieEditKeys         = 'EditKeys';
 
 
 
 
 Procedure InitDirs;
 Procedure InitDirs;
@@ -413,6 +415,15 @@ begin
   MouseReverse:=boolean(INIFile^.GetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse)));
   MouseReverse:=boolean(INIFile^.GetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse)));
   AltMouseAction:=INIFile^.GetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
   AltMouseAction:=INIFile^.GetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
   CtrlMouseAction:=INIFile^.GetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
   CtrlMouseAction:=INIFile^.GetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
+  {Keyboard}
+  case crc32(upcase(INIFile^.GetEntry(secKeyboard,ieEditKeys,''))) of
+    $86a4c898: {crc32 for 'MICROSOFT'} 
+      EditKeys:=ekm_microsoft;
+    $b20b87b3: {crc32 for 'BORLAND'}
+      EditKeys:=ekm_borland;
+    else
+      EditKeys:=ekm_default;
+  end;
   { Search }
   { Search }
   FindFlags:=INIFile^.GetIntEntry(secSearch,ieFindFlags,FindFlags);
   FindFlags:=INIFile^.GetIntEntry(secSearch,ieFindFlags,FindFlags);
   { Breakpoints }
   { Breakpoints }
@@ -601,6 +612,11 @@ begin
   INIFile^.SetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse));
   INIFile^.SetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse));
   INIFile^.SetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
   INIFile^.SetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
   INIFile^.SetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
   INIFile^.SetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
+  { Keyboard }
+  if EditKeys=ekm_microsoft then
+    INIFile^.SetEntry(secKeyboard,ieEditKeys,'microsoft')
+  else
+    INIFile^.SetEntry(secKeyboard,ieEditKeys,'borland');
   { Search }
   { Search }
   INIFile^.SetIntEntry(secSearch,ieFindFlags,FindFlags);
   INIFile^.SetIntEntry(secSearch,ieFindFlags,FindFlags);
   { Breakpoints }
   { Breakpoints }

+ 13 - 8
ide/fpstre.inc

@@ -27,10 +27,11 @@ const
       menu_common_prevtopic    = '~P~revious topic';
       menu_common_prevtopic    = '~P~revious topic';
       menu_common_copy = '~C~opy';
       menu_common_copy = '~C~opy';
 
 
-      menu_key_common_helpindex = 'Shift+F1';
-      menu_key_common_topicsearch = 'Ctrl+F1';
-      menu_key_common_prevtopic = 'Alt+F1';
-      menu_key_common_copy = 'Ctrl+Ins';
+      menu_key_common_helpindex      = 'Shift+F1';
+      menu_key_common_topicsearch    = 'Ctrl+F1';
+      menu_key_common_prevtopic      = 'Alt+F1';
+      menu_key_common_copy_borland   = 'Ctrl+Ins';
+      menu_key_common_copy_microsoft = 'Ctrl+C';
 
 
       { Symbol browser tabs }
       { Symbol browser tabs }
       label_browsertab_scope = 'S';
       label_browsertab_scope = 'S';
@@ -216,9 +217,12 @@ const
       menu_key_file_exit     = 'Alt+X';
       menu_key_file_exit     = 'Alt+X';
 
 
       menu_key_edit_undo     = 'Alt+BkSp';
       menu_key_edit_undo     = 'Alt+BkSp';
-      menu_key_edit_cut      = 'Shift+Del';
-      menu_key_edit_copy     = menu_key_common_copy;
-      menu_key_edit_paste    = 'Shift+Ins';
+      menu_key_edit_cut_borland      = 'Shift+Del';
+      menu_key_edit_copy_borland     = menu_key_common_copy_borland;
+      menu_key_edit_paste_borland    = 'Shift+Ins';
+      menu_key_edit_cut_microsoft    = 'Ctrl+X';
+      menu_key_edit_copy_microsoft   = menu_key_common_copy_microsoft;
+      menu_key_edit_paste_microsoft  = 'Ctrl+V';
       menu_key_edit_clear    = 'Ctrl+Del';
       menu_key_edit_clear    = 'Ctrl+Del';
 
 
       menu_key_run_run       = 'Ctrl+F9';
       menu_key_run_run       = 'Ctrl+F9';
@@ -256,7 +260,8 @@ const
       menu_key_hlplocal_index = menu_key_common_helpindex;
       menu_key_hlplocal_index = menu_key_common_helpindex;
       menu_key_hlplocal_topicsearch = menu_key_common_topicsearch;
       menu_key_hlplocal_topicsearch = menu_key_common_topicsearch;
       menu_key_hlplocal_prevtopic = menu_key_common_prevtopic;
       menu_key_hlplocal_prevtopic = menu_key_common_prevtopic;
-      menu_key_hlplocal_copy = menu_key_common_copy;
+      menu_key_hlplocal_copy_borland = menu_key_common_copy_borland;
+      menu_key_hlplocal_copy_microsoft = menu_key_common_copy_microsoft;
 
 
       dialog_openafile        = 'Open a file';
       dialog_openafile        = 'Open a file';
       label_filetoopen        = 'File to ope~n~';
       label_filetoopen        = 'File to ope~n~';

+ 16 - 0
ide/fpvars.pas

@@ -33,6 +33,20 @@ type
     TCompPhase = (cpNothing,cpCompiling,cpLinking,
     TCompPhase = (cpNothing,cpCompiling,cpLinking,
                   cpAborted,cpFailed,cpDone);
                   cpAborted,cpFailed,cpDone);
 
 
+    {Use edit keys according to Borland convention (shift+del,ctrl+ins,shift+ins)
+     or Microsoft convention (ctrl+x,ctrl+c,ctrl+v).}
+    Tedit_key_modes=(ekm_borland,ekm_microsoft);
+
+
+{$ifdef Unix}
+      {Microsoft convention is default on Unix, because the Borland "paste" key, Shift+Ins,
+       is not passed on to the program in most X terminal emulators.}
+const ekm_default = ekm_microsoft;
+{$else}
+      ekm_default = ekm_borland;
+{$endif}
+
+
 const ClipboardWindow  : PClipboardWindow = nil;
 const ClipboardWindow  : PClipboardWindow = nil;
       CalcWindow       : PCalculator = nil;
       CalcWindow       : PCalculator = nil;
       RecentFileCount  : integer = 0;
       RecentFileCount  : integer = 0;
@@ -103,6 +117,8 @@ const ClipboardWindow  : PClipboardWindow = nil;
       ShowReadme       : boolean = true;
       ShowReadme       : boolean = true;
       AskRecompileIfModifiedFlag : boolean = true;
       AskRecompileIfModifiedFlag : boolean = true;
 
 
+      EditKeys:Tedit_key_modes = ekm_default;
+
 {$ifdef SUPPORT_REMOTE}
 {$ifdef SUPPORT_REMOTE}
      RemoteMachine : string = '';
      RemoteMachine : string = '';
      RemotePort : string = '2345';
      RemotePort : string = '2345';

+ 4 - 4
ide/fpviews.pas

@@ -1672,9 +1672,9 @@ var M: PMenu;
     MI: PMenuItem;
     MI: PMenuItem;
 begin
 begin
   MI:=
   MI:=
-    NewItem(menu_edit_cut,menu_key_edit_cut,kbShiftDel,cmCut,hcCut,
-    NewItem(menu_edit_copy,menu_key_edit_copy,kbCtrlIns,cmCopy,hcCopy,
-    NewItem(menu_edit_paste,menu_key_edit_paste,kbShiftIns,cmPaste,hcPaste,
+    NewItem(menu_edit_cut,menu_key_edit_cut,cut_key,cmCut,hcCut,
+    NewItem(menu_edit_copy,menu_key_edit_copy,copy_key,cmCopy,hcCopy,
+    NewItem(menu_edit_paste,menu_key_edit_paste,paste_key,cmPaste,hcPaste,
     NewItem(menu_edit_clear,menu_key_edit_clear,kbCtrlDel,cmClear,hcClear,
     NewItem(menu_edit_clear,menu_key_edit_clear,kbCtrlDel,cmClear,hcClear,
     NewLine(
     NewLine(
     NewItem(menu_srclocal_openfileatcursor,'',kbNoKey,cmOpenAtCursor,hcOpenAtCursor,
     NewItem(menu_srclocal_openfileatcursor,'',kbNoKey,cmOpenAtCursor,hcOpenAtCursor,
@@ -1962,7 +1962,7 @@ begin
     NewItem(menu_hlplocal_topicsearch,menu_key_hlplocal_topicsearch,kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
     NewItem(menu_hlplocal_topicsearch,menu_key_hlplocal_topicsearch,kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
     NewItem(menu_hlplocal_prevtopic,menu_key_hlplocal_prevtopic,kbAltF1,cmHelpPrevTopic,hcHelpPrevTopic,
     NewItem(menu_hlplocal_prevtopic,menu_key_hlplocal_prevtopic,kbAltF1,cmHelpPrevTopic,hcHelpPrevTopic,
     NewLine(
     NewLine(
-    NewItem(menu_hlplocal_copy,menu_key_hlplocal_copy,kbCtrlIns,cmCopy,hcCopy,
+    NewItem(menu_hlplocal_copy,menu_key_hlplocal_copy,copy_key,cmCopy,hcCopy,
     nil)))))));
     nil)))))));
   GetLocalMenu:=M;
   GetLocalMenu:=M;
 end;
 end;