Commit c4bc7bb4 authored by charras's avatar charras

enhancements about hot keys

parent 5861a43d
......@@ -1344,6 +1344,13 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
if( event.ShiftDown() && (key > 256) )
localkey |= GR_KB_SHIFT;
/* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
* They have an ascii code from 1 to 27 remapped
* GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z'
*/
if( (localkey & (GR_KB_CTRL|GR_KB_ALT|GR_KB_SHIFT)) == GR_KB_CTRL )
localkey += 'A' - 1;
INSTALL_DC( DC, this );
BASE_SCREEN* Screen = GetScreen();
......
......@@ -61,7 +61,6 @@ struct hotkey_name_descr
int m_KeyCode;
};
static struct hotkey_name_descr s_Hotkey_Name_List[] =
{
{ wxT( "F1" ), WXK_F1 },
......@@ -78,15 +77,15 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
{ wxT( "F12" ), WXK_F12 },
{ wxT( "Esc" ), WXK_ESCAPE },
{ wxT( "Delete" ), WXK_DELETE },
{ wxT( "Del" ), WXK_DELETE },
{ wxT( "Tab" ), '\t' },
{ wxT( "Backspace" ), WXK_BACK },
{ wxT( "Insert" ), WXK_INSERT },
{ wxT( "BkSp" ), WXK_BACK },
{ wxT( "Ins" ), WXK_INSERT },
{ wxT( "Home" ), WXK_HOME },
{ wxT( "End" ), WXK_END },
{ wxT( "Page Up" ), WXK_PAGEUP },
{ wxT( "Page Down" ), WXK_PAGEDOWN },
{ wxT( "PgUp" ), WXK_PAGEUP },
{ wxT( "PgDn" ), WXK_PAGEDOWN },
{ wxT( "+" ), '+' },
{ wxT( "-" ), '-' },
......@@ -131,34 +130,68 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
{ wxT( "Y" ), 'Y' },
{ wxT( "Z" ), 'Z' },
{ wxT( "Ctrl A" ), GR_KB_CTRL + 'A' },
{ wxT( "Ctrl B" ), GR_KB_CTRL + 'B' },
{ wxT( "Ctrl C" ), GR_KB_CTRL + 'C' },
{ wxT( "Ctrl D" ), GR_KB_CTRL + 'D' },
{ wxT( "Ctrl E" ), GR_KB_CTRL + 'E' },
{ wxT( "Ctrl F" ), GR_KB_CTRL + 'F' },
{ wxT( "Ctrl G" ), GR_KB_CTRL + 'G' },
{ wxT( "Ctrl H" ), GR_KB_CTRL + 'H' },
{ wxT( "Ctrl I" ), GR_KB_CTRL + 'I' },
{ wxT( "Ctrl J" ), GR_KB_CTRL + 'J' },
{ wxT( "Ctrl K" ), GR_KB_CTRL + 'K' },
{ wxT( "Ctrl L" ), GR_KB_CTRL + 'L' },
{ wxT( "Ctrl M" ), GR_KB_CTRL + 'M' },
{ wxT( "Ctrl N" ), GR_KB_CTRL + 'N' },
{ wxT( "Ctrl O" ), GR_KB_CTRL + 'O' },
{ wxT( "Ctrl P" ), GR_KB_CTRL + 'P' },
{ wxT( "Ctrl Q" ), GR_KB_CTRL + 'Q' },
{ wxT( "Ctrl R" ), GR_KB_CTRL + 'R' },
{ wxT( "Ctrl S" ), GR_KB_CTRL + 'S' },
{ wxT( "Ctrl T" ), GR_KB_CTRL + 'T' },
{ wxT( "Ctrl U" ), GR_KB_CTRL + 'U' },
{ wxT( "Ctrl V" ), GR_KB_CTRL + 'V' },
{ wxT( "Ctrl W" ), GR_KB_CTRL + 'W' },
{ wxT( "Ctrl X" ), GR_KB_CTRL + 'X' },
{ wxT( "Ctrl Y" ), GR_KB_CTRL + 'Y' },
{ wxT( "Ctrl Z" ), GR_KB_CTRL + 'Z' },
{ wxT( "" ), 0 } // Do not change: end of list
{ wxT( "Ctrl++" ), GR_KB_CTRL + '+' },
{ wxT( "Ctrl+-" ), GR_KB_CTRL + '-' },
{ wxT( "Ctrl+A" ), GR_KB_CTRL + 'A' },
{ wxT( "Ctrl+B" ), GR_KB_CTRL + 'B' },
{ wxT( "Ctrl+C" ), GR_KB_CTRL + 'C' },
{ wxT( "Ctrl+D" ), GR_KB_CTRL + 'D' },
{ wxT( "Ctrl+E" ), GR_KB_CTRL + 'E' },
{ wxT( "Ctrl+F" ), GR_KB_CTRL + 'F' },
{ wxT( "Ctrl+G" ), GR_KB_CTRL + 'G' },
{ wxT( "Ctrl+H" ), GR_KB_CTRL + 'H' },
{ wxT( "Ctrl+I" ), GR_KB_CTRL + 'I' },
{ wxT( "Ctrl+J" ), GR_KB_CTRL + 'J' },
{ wxT( "Ctrl+K" ), GR_KB_CTRL + 'K' },
{ wxT( "Ctrl+L" ), GR_KB_CTRL + 'L' },
{ wxT( "Ctrl+M" ), GR_KB_CTRL + 'M' },
{ wxT( "Ctrl+N" ), GR_KB_CTRL + 'N' },
{ wxT( "Ctrl+O" ), GR_KB_CTRL + 'O' },
{ wxT( "Ctrl+P" ), GR_KB_CTRL + 'P' },
{ wxT( "Ctrl+Q" ), GR_KB_CTRL + 'Q' },
{ wxT( "Ctrl+R" ), GR_KB_CTRL + 'R' },
{ wxT( "Ctrl+S" ), GR_KB_CTRL + 'S' },
{ wxT( "Ctrl+T" ), GR_KB_CTRL + 'T' },
{ wxT( "Ctrl+U" ), GR_KB_CTRL + 'U' },
{ wxT( "Ctrl+V" ), GR_KB_CTRL + 'V' },
{ wxT( "Ctrl+W" ), GR_KB_CTRL + 'W' },
{ wxT( "Ctrl+X" ), GR_KB_CTRL + 'X' },
{ wxT( "Ctrl+Y" ), GR_KB_CTRL + 'Y' },
{ wxT( "Ctrl+Z" ), GR_KB_CTRL + 'Z' },
{ wxT( "Shift+Ctrl++" ), GR_KB_SHIFT + GR_KB_CTRL + '+' },
{ wxT( "Shift+Ctrl+-" ), GR_KB_SHIFT + GR_KB_CTRL + '-' },
{ wxT( "Shift+Ctrl+A" ), GR_KB_SHIFT + GR_KB_CTRL + 'A' },
{ wxT( "Shift+Ctrl+B" ), GR_KB_SHIFT + GR_KB_CTRL + 'B' },
{ wxT( "Shift+Ctrl+C" ), GR_KB_SHIFT + GR_KB_CTRL + 'C' },
{ wxT( "Shift+Ctrl+D" ), GR_KB_SHIFT + GR_KB_CTRL + 'D' },
{ wxT( "Shift+Ctrl+E" ), GR_KB_SHIFT + GR_KB_CTRL + 'E' },
{ wxT( "Shift+Ctrl+F" ), GR_KB_SHIFT + GR_KB_CTRL + 'F' },
{ wxT( "Shift+Ctrl+G" ), GR_KB_SHIFT + GR_KB_CTRL + 'G' },
{ wxT( "Shift+Ctrl+H" ), GR_KB_SHIFT + GR_KB_CTRL + 'H' },
{ wxT( "Shift+Ctrl+I" ), GR_KB_SHIFT + GR_KB_CTRL + 'I' },
{ wxT( "Shift+Ctrl+J" ), GR_KB_SHIFT + GR_KB_CTRL + 'J' },
{ wxT( "Shift+Ctrl+K" ), GR_KB_SHIFT + GR_KB_CTRL + 'K' },
{ wxT( "Shift+Ctrl+L" ), GR_KB_SHIFT + GR_KB_CTRL + 'L' },
{ wxT( "Shift+Ctrl+M" ), GR_KB_SHIFT + GR_KB_CTRL + 'M' },
{ wxT( "Shift+Ctrl+N" ), GR_KB_SHIFT + GR_KB_CTRL + 'N' },
{ wxT( "Shift+Ctrl+O" ), GR_KB_SHIFT + GR_KB_CTRL + 'O' },
{ wxT( "Shift+Ctrl+P" ), GR_KB_SHIFT + GR_KB_CTRL + 'P' },
{ wxT( "Shift+Ctrl+Q" ), GR_KB_SHIFT + GR_KB_CTRL + 'Q' },
{ wxT( "Shift+Ctrl+R" ), GR_KB_SHIFT + GR_KB_CTRL + 'R' },
{ wxT( "Shift+Ctrl+S" ), GR_KB_SHIFT + GR_KB_CTRL + 'S' },
{ wxT( "Shift+Ctrl+T" ), GR_KB_SHIFT + GR_KB_CTRL + 'T' },
{ wxT( "Shift+Ctrl+U" ), GR_KB_SHIFT + GR_KB_CTRL + 'U' },
{ wxT( "Shift+Ctrl+V" ), GR_KB_SHIFT + GR_KB_CTRL + 'V' },
{ wxT( "Shift+Ctrl+W" ), GR_KB_SHIFT + GR_KB_CTRL + 'W' },
{ wxT( "Shift+Ctrl+X" ), GR_KB_SHIFT + GR_KB_CTRL + 'X' },
{ wxT( "Shift+Ctrl+Y" ), GR_KB_SHIFT + GR_KB_CTRL + 'Y' },
{ wxT( "Shift+Ctrl+Z" ), GR_KB_SHIFT + GR_KB_CTRL + 'Z' },
// Do not change this line: end of list
{ wxT( "" ), 0 }
};
......@@ -175,11 +208,11 @@ wxString ReturnKeyNameFromKeyCode( int keycode )
int ii;
if( (keycode & GR_KB_CTRL) != 0 )
modifier << wxT( "Ctrl " );
modifier << wxT( "Ctrl+" );
if( (keycode & GR_KB_ALT) != 0 )
modifier << wxT( "Alt " );
modifier << wxT( "Alt+" );
if( (keycode & GR_KB_SHIFT) != 0 )
modifier << wxT( "Shift " );
modifier << wxT( "Shift+" );
keycode &= ~( GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT );
for( ii = 0; ; ii++ )
......@@ -214,7 +247,7 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List,
wxString keyname = ReturnKeyNameFromCommandId( List, CommandId );
if( !keyname.IsEmpty() )
msg << wxT( " (" ) << keyname << wxT( ")" );
msg << wxT( "\t" ) << keyname;
return msg;
}
......@@ -240,7 +273,7 @@ wxString AddHotkeyName( const wxString& text,
keyname = ReturnKeyNameFromCommandId( List, CommandId );
if( !keyname.IsEmpty() )
{
msg << wxT( " (" ) << keyname << wxT( ")" );
msg << wxT( "\t" ) << keyname;
break;
}
}
......@@ -304,7 +337,7 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
* Displays the current hotkey list
* @param frame = current active frame
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor list
* (Null terminated)
*(Null terminated)
* @return none
*/
void DisplayHotkeyList( WinEDA_DrawFrame* frame,
......@@ -595,6 +628,7 @@ wxString ReturnHotkeyConfigFilePath( int choice )
wxFileName::GetPathSeparator();
case 1:
/* TODO: This is broken under a normal Poxis system. Users
* generally do no have write permissions to this path
* and there is no provision for prompting for the root
......@@ -634,7 +668,8 @@ void AddHotkeyConfigMenu( wxMenu* aMenu )
/* (Re)create hotkey file */
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_CREATE_CONFIG,
_( "(Re)create Hotkeys File" ),
_( "Create or recreate the hotkey configuration file from current hotkey list" )
_(
"Create or recreate the hotkey configuration file from current hotkey list" )
);
item->SetBitmap( save_setup_xpm );
HotkeySubmenu->Append( item );
......@@ -656,7 +691,7 @@ void AddHotkeyConfigMenu( wxMenu* aMenu )
/* Append HotkeySubmenu to menu */
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( aMenu, HotkeySubmenu,
ID_PREFERENCES_HOTKEY_SUBMENU, _( "Hotkeys" ),
_("Hotkeys configuration and preferences" ), hotkeys_xpm );
_( "Hotkeys configuration and preferences" ), hotkeys_xpm );
/* Hotkey path */
wxMenu* HotkeyLocationSubmenu = new wxMenu();
......
......@@ -233,10 +233,6 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
wxPoint MousePos = GetScreen()->m_MousePosition;
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to
// handle...)
if( (hotkey & GR_KB_CTRL) != 0 )
hotkey += 'A' - 1;
/* Convert lower to upper case (the usual toupper function has problem
* with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
......@@ -640,11 +636,6 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
if( hotkey == 0 )
return;
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to
// handle...)
if( (hotkey & GR_KB_CTRL) != 0 )
hotkey += 'A' - 1;
/* Convert lower to upper case (the usual toupper function has problem
* with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
......
......@@ -151,11 +151,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
wxMenu* editMenu = new wxMenu;
/* Undo */
#if !defined( __WXMAC__)
text = AddHotkeyName( _( "Undo" ), s_Schematic_Hokeys_Descr, HK_UNDO);
#else
text = _( "Undo\tCtrl+Z" );
#endif
item = new wxMenuItem( editMenu, wxID_UNDO, text,
_( "Undo last edition" ), wxITEM_NORMAL );
......@@ -163,11 +159,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
editMenu->Append( item );
/* Redo */
#if !defined( __WXMAC__)
text = AddHotkeyName( _( "Redo" ), s_Schematic_Hokeys_Descr, HK_REDO);
#else
text = _( "Redo\tShift+Ctrl+Z" );
#endif
item = new wxMenuItem( editMenu, wxID_REDO, text,
_( "Redo the last undo command" ), wxITEM_NORMAL );
......
......@@ -60,16 +60,10 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
return true;
}
if (DrawStruct)
cout << "Drawstruct Type before: " << DrawStruct -> Type() << endl;
// Try to locate items at cursor position.
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = SchematicGeneralLocateAndDisplay( false );
if (DrawStruct)
cout << "Drawstruct Type locate : " << DrawStruct -> Type() << endl;
if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) )
{
......@@ -81,9 +75,6 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
}
}
if (DrawStruct)
cout << "Drawstruct Type : " << DrawStruct -> Type() << endl;
// If Command in progress: add "cancel" and "end tool" menu
if( m_ID_current_state )
{
......
......@@ -84,9 +84,6 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey,
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to handle...)
if( (hotkey & GR_KB_CTRL) != 0 )
hotkey += 'A' - 1;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a';
......
......@@ -218,10 +218,6 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
MODULE* module = NULL;
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (just easier to handle...)
if( (hotkey & GR_KB_CTRL) != 0 )
hotkey += 'A' - 1;
/* Convert lower to upper case
* (the usual toupper function has problem with non ascii codes like function keys
*/
......@@ -676,10 +672,6 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (just easier to handle...)
if( (hotkey & GR_KB_CTRL) != 0 )
hotkey += 'A' - 1;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment