Skip to content

Commit

Permalink
- Visualize whitespace in editors.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25575 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 16, 2015
1 parent d8230ff commit c587032
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions OMEdit/OMEditGUI/Editors/BaseEditor.cpp
Expand Up @@ -476,6 +476,11 @@ void BaseEditor::createActions()
mpGotoLineNumberAction->setStatusTip(tr("Shows the Go to Line Number window"));
mpGotoLineNumberAction->setShortcut(QKeySequence("Ctrl+l"));
connect(mpGotoLineNumberAction, SIGNAL(triggered()), SLOT(showGotoLineNumberDialog()));
// ShowTabsAndSpaces action
mpShowTabsAndSpacesAction = new QAction(tr("Show Tabs and Spaces"), this);
mpShowTabsAndSpacesAction->setStatusTip(tr("Shows the Tabs and Spaces"));
mpShowTabsAndSpacesAction->setCheckable(true);
connect(mpShowTabsAndSpacesAction, SIGNAL(triggered(bool)), SLOT(showTabsAndSpaces(bool)));
/* Toggle breakpoint action */
mpToggleBreakpointAction = new QAction(tr("Toggle Breakpoint"), this);
connect(mpToggleBreakpointAction, SIGNAL(triggered()), SLOT(toggleBreakpoint()));
Expand All @@ -497,6 +502,8 @@ QMenu* BaseEditor::createStandardContextMenu()
pMenu->addAction(mpFindReplaceAction);
pMenu->addAction(mpClearFindReplaceTextsAction);
pMenu->addAction(mpGotoLineNumberAction);
pMenu->addSeparator();
pMenu->addAction(mpShowTabsAndSpacesAction);
return pMenu;
}

Expand Down Expand Up @@ -575,6 +582,22 @@ void BaseEditor::showGotoLineNumberDialog()
pGotoLineWidget->exec();
}

/*!
* \brief BaseEditor::showTabsAndSpaces
* Shows/hide tabs and spaces for the editor.
* \param On
*/
void BaseEditor::showTabsAndSpaces(bool On)
{
QTextOption textOption = mpPlainTextEdit->document()->defaultTextOption();
if (On) {
textOption.setFlags(textOption.flags() | QTextOption::ShowTabsAndSpaces);
} else {
textOption.setFlags(textOption.flags() & ~QTextOption::ShowTabsAndSpaces);
}
mpPlainTextEdit->document()->setDefaultTextOption(textOption);
}

/**
* Slot activated when set breakpoint is seleteted from line number area context menu.
*/
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Editors/BaseEditor.h
Expand Up @@ -97,6 +97,7 @@ class BaseEditor : public QWidget
QAction *mpFindReplaceAction;
QAction *mpClearFindReplaceTextsAction;
QAction *mpGotoLineNumberAction;
QAction *mpShowTabsAndSpacesAction;
QAction *mpToggleBreakpointAction;
QAction *mpToggleCommentSelectionAction;
DocumentMarker *mpDocumentMarker;
Expand All @@ -114,6 +115,7 @@ public slots:
void showFindReplaceWidget();
void clearFindReplaceTexts();
void showGotoLineNumberDialog();
void showTabsAndSpaces(bool On);
void toggleBreakpoint();
virtual void toggleCommentSelection() = 0;
void indentOrUnindent(bool doIndent);
Expand Down

0 comments on commit c587032

Please sign in to comment.