Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut improvements #3635

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ void ShortcutMapper::initBabyGrid() {

_babygrid.reSizeToWH(rect);
_babygrid.hideCursor();
_babygrid.makeColAutoWidth();
_babygrid.makeColAutoWidth(false);
_babygrid.setAutoRow(false);
_babygrid.setColsNumbered(false);
_babygrid.setColWidth(0, NppParameters::getInstance()->_dpiManager.scaleX(30));
_babygrid.setColWidth(1, NppParameters::getInstance()->_dpiManager.scaleX(250));
_babygrid.setColWidth(1, NppParameters::getInstance()->_dpiManager.scaleX(290));
_babygrid.setColWidth(2, NppParameters::getInstance()->_dpiManager.scaleX(140));
_babygrid.setColWidth(3, NppParameters::getInstance()->_dpiManager.scaleX(40));
_babygrid.setHeaderHeight(NppParameters::getInstance()->_dpiManager.scaleY(21));
_babygrid.setRowHeight(NppParameters::getInstance()->_dpiManager.scaleY(21));

Expand All @@ -130,10 +132,14 @@ void ShortcutMapper::fillOutBabyGrid()

size_t nbItems = 0;

_babygrid.setText(0, 1, TEXT("Name"));
_babygrid.setText(0, 2, TEXT("Shortcut"));

switch(_currentState) {
case STATE_MENU: {
nbItems = nppParam->getUserShortcuts().size();
_babygrid.setLineColNumber(nbItems, 2);
_babygrid.setLineColNumber(nbItems, 3);
_babygrid.setText(0, 3, TEXT("Category"));
break; }
case STATE_MACRO: {
nbItems = nppParam->getMacroList().size();
Expand All @@ -145,17 +151,15 @@ void ShortcutMapper::fillOutBabyGrid()
break; }
case STATE_PLUGIN: {
nbItems = nppParam->getPluginCommandList().size();
_babygrid.setLineColNumber(nbItems, 2);
_babygrid.setLineColNumber(nbItems, 3);
_babygrid.setText(0, 3, TEXT("Plugin"));
break; }
case STATE_SCINTILLA: {
nbItems = nppParam->getScintillaKeyList().size();
_babygrid.setLineColNumber(nbItems, 2);
break; }
}

_babygrid.setText(0, 1, TEXT("Name"));
_babygrid.setText(0, 2, TEXT("Shortcut"));

bool isMarker = false;

switch(_currentState) {
Expand All @@ -169,7 +173,7 @@ void ShortcutMapper::fillOutBabyGrid()
_babygrid.setText(i+1, 1, cshortcuts[i].getName());
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());

_babygrid.setText(i+1, 3, cshortcuts[i].getCategory());
if (isMarker)
isMarker = _babygrid.setMarker(false);
}
Expand Down Expand Up @@ -225,6 +229,7 @@ void ShortcutMapper::fillOutBabyGrid()
_babygrid.setText(i+1, 1, cshortcuts[i].getName());
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
_babygrid.setText(i+1, 3, cshortcuts[i].getModuleName());

if (isMarker)
isMarker = _babygrid.setMarker(false);
Expand Down
36 changes: 35 additions & 1 deletion PowerEditor/src/WinControls/shortcut/shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,14 @@ void Shortcut::setName(const TCHAR * name) {
}

generic_string ScintillaKeyMap::toString() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return toString(0);
generic_string sc = TEXT("");
size_t nbCombos = getSize();
for (size_t combo = 0; combo < nbCombos; ++combo){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad style;

sc += toString(combo);
if (combo < nbCombos - 1)
sc += TEXT(" or ");
}
return sc;
}

generic_string ScintillaKeyMap::toString(size_t index) const {
Expand Down Expand Up @@ -948,3 +955,30 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA

//return FALSE;
}

CommandShortcut::CommandShortcut(Shortcut sc, long id) : Shortcut(sc), _id(id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad style.

if ( _id < IDM_EDIT)
_category = TEXT("File");
else if ( _id < IDM_SEARCH)
_category = TEXT("Edit");
else if (_id >= IDM_EDIT_AUTOCOMPLETE and _id <= IDM_EDIT_AUTOCOMPLETE_PATH)
_category = TEXT("Edit");
else if ( _id < IDM_VIEW)
_category = TEXT("Search");
else if ( _id < IDM_FORMAT)
_category = TEXT("View");
else if ( _id >= IDM_VIEW_GOTO_ANOTHER_VIEW and _id <= IDM_VIEW_LOAD_IN_NEW_INSTANCE)
_category = TEXT("View");
else if ( _id < IDM_LANG)
_category = TEXT("Format");
else if ( _id < IDM_ABOUT)
_category = TEXT("Lang");
else if ( _id < IDM_SETTING)
_category = TEXT("About");
else if ( _id < IDM_TOOL)
_category = TEXT("Setting");
else if ( _id < IDM_EXECUTE)
_category = TEXT("Tool");
else
_category = TEXT("Execute");
}
5 changes: 4 additions & 1 deletion PowerEditor/src/WinControls/shortcut/shortcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Scintilla.h"
#include "StaticDialog.h"
#include "Common.h"
#include "menuCmdID.h"

const size_t nameLenMax = 64;

Expand Down Expand Up @@ -193,12 +194,14 @@ protected :

class CommandShortcut : public Shortcut {
public:
CommandShortcut(Shortcut sc, long id) : Shortcut(sc), _id(id) {};
CommandShortcut(Shortcut sc, long id);
unsigned long getID() const {return _id;};
void setID(unsigned long id) { _id = id;};
const TCHAR * getCategory() const { return _category.c_str(); };

private :
unsigned long _id;
generic_string _category;
};


Expand Down