Skip to content

Commit

Permalink
Merge pull request #1272 from vdonnefort/scide/ctrl+w
Browse files Browse the repository at this point in the history
scide: add OSX delete word ctrl+w shortcut
  • Loading branch information
crucialfelix committed Nov 7, 2015
2 parents 1c76ff0 + 007a8a3 commit cf99448
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions editors/sc-ide/widgets/code_editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,18 @@ void GenericCodeEditor::moveLineDown()
moveLineUpDown(false);
}

void GenericCodeEditor::deleteWord()
{
QTextCursor cur = textCursor();

cur.beginEditBlock();

cur.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
cur.deletePreviousChar();

cur.endEditBlock();
}

void GenericCodeEditor::gotoPreviousEmptyLine()
{
gotoEmptyLineUpDown(true);
Expand Down
1 change: 1 addition & 0 deletions editors/sc-ide/widgets/code_editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public slots:
void copyLineDown();
void moveLineUp();
void moveLineDown();
void deleteWord();
void gotoPreviousEmptyLine();
void gotoNextEmptyLine();
void setActiveAppearance(bool active);
Expand Down
11 changes: 11 additions & 0 deletions editors/sc-ide/widgets/multi_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ void MultiEditor::createActions()
mEditorSigMux->connect(action, SIGNAL(triggered()), SLOT(moveLineDown()));
settings->addAction( action, "editor-move-line-down", editorCategory);

mActions[DeleteWord] = action = new QAction(
QIcon::fromTheme("edit-deleteword"), tr("Delete Word"), this);
#ifdef Q_OS_MAC
action->setShortcut(tr("Meta+W", "Delete Word"));
#endif
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
mEditorSigMux->connect(action, SIGNAL(triggered()), SLOT(deleteWord()));
settings->addAction(action, "delete-word", editorCategory);

mActions[GotoPreviousBlock] = action = new QAction(
QIcon::fromTheme("edit-gotopreviousblock"), tr("Go to Previous Block"), this);
action->setShortcut(tr("Ctrl+[", "Go to Previous Block"));
Expand Down Expand Up @@ -687,6 +696,7 @@ void MultiEditor::createActions()
addAction(mActions[CopyLineDown]);
addAction(mActions[MoveLineUp]);
addAction(mActions[MoveLineDown]);
addAction(mActions[DeleteWord]);
addAction(mActions[GotoPreviousBlock]);
addAction(mActions[GotoNextBlock]);
addAction(mActions[SelectEnclosingBlock]);
Expand All @@ -713,6 +723,7 @@ void MultiEditor::updateActions()
mActions[CopyLineDown]->setEnabled( editor );
mActions[MoveLineUp]->setEnabled( editor );
mActions[MoveLineDown]->setEnabled( editor );
mActions[DeleteWord]->setEnabled( editor );
mActions[GotoPreviousEmptyLine]->setEnabled( editor );
mActions[GotoNextEmptyLine]->setEnabled( editor );
mActions[DocClose]->setEnabled( editor );
Expand Down
1 change: 1 addition & 0 deletions editors/sc-ide/widgets/multi_editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class MultiEditor : public QWidget
CopyLineDown,
MoveLineUp,
MoveLineDown,
DeleteWord,

GotoPreviousBlock,
GotoNextBlock,
Expand Down

0 comments on commit cf99448

Please sign in to comment.