Commit 7f6d1009 authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Tomaz Canabrava
Browse files

Add profile options to enable semantic integration options

- The line separating commands may appear never, always, or when showing
  URL hints.
- Up/Down arrows may be translated to a number of Left/Right arrows.

A UI for those options was also added.
parent 98d8ea42
......@@ -59,6 +59,14 @@ public:
ScrollPageFull = 1,
};
/** This enum describes semantic hints appearance
*/
enum SemanticHints {
SemanticHintsNever = 0,
SemanticHintsURL = 1,
SemanticHintsAlways = 2,
};
/** This enum describes the shapes used to draw the cursor in terminal
* displays.
*/
......
......@@ -2157,7 +2157,8 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent *event)
int cuX = _currentScreen->getCursorX();
int cuY = _currentScreen->getCursorY();
if ((event->key() == Qt::Key_Up || event->key() == Qt::Key_Down) && _currentScreen->replMode() == REPL_INPUT) {
if ((event->key() == Qt::Key_Up || event->key() == Qt::Key_Down) && _currentScreen->replMode() == REPL_INPUT
&& _currentScreen->currentTerminalDisplay()->semanticUpDown()) {
if ((event->key() == Qt::Key_Up && _currentScreen->replModeStart() <= std::make_pair(cuY - 1, cuX))
|| (event->key() == Qt::Key_Down && std::make_pair(cuY + 1, cuX) <= _currentScreen->replModeEnd())) {
entry = _keyTranslator->findEntry(event->key() == Qt::Key_Up ? Qt::Key_Left : Qt::Key_Right, Qt::NoModifier, states);
......
......@@ -349,7 +349,16 @@ public:
ColorFilterEnabled,
/** (bool) Allows mouse tracking */
AllowMouseTracking
AllowMouseTracking,
/** (int) Show semantic hints (lines between commands, lighter input):
* 0 for Never, 1 when showing URL hints, 2 for always
*/
SemanticHints,
/** (bool) If true, convert Up/Down arrows when in input mode to Left/Right
* key presses that emulate the same cursor movement
*/
SemanticUpDown,
};
Q_ENUM(Property)
......@@ -740,6 +749,16 @@ public:
return QKeySequence::fromString(property<QString>(Profile::PeekPrimaryKeySequence));
}
int semanticHints() const
{
return property<int>(Profile::SemanticHints);
}
bool semanticUpDown() const
{
return property<bool>(Profile::SemanticUpDown);
}
/** Return a list of all properties names and their type
* (for use with -p option).
*/
......
......@@ -2828,6 +2828,8 @@ void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
_ctrlRequiredForDrag = profile->property<bool>(Profile::CtrlRequiredForDrag);
_dropUrlsAsText = profile->property<bool>(Profile::DropUrlsAsText);
_bidiEnabled = profile->bidiRenderingEnabled();
_semanticUpDown = profile->semanticUpDown();
_semanticHints = profile->semanticHints();
_trimLeadingSpaces = profile->property<bool>(Profile::TrimLeadingSpacesInSelectedText);
_trimTrailingSpaces = profile->property<bool>(Profile::TrimTrailingSpacesInSelectedText);
_openLinksByDirectClick = profile->property<bool>(Profile::OpenLinksByDirectClickEnabled);
......
......@@ -335,6 +335,16 @@ public:
return _bidiEnabled;
}
bool semanticUpDown() const
{
return _semanticUpDown;
}
int semanticHints() const
{
return _semanticHints;
}
ColorSchemeWallpaper::Ptr wallpaper() const
{
return _wallpaper;
......@@ -763,6 +773,9 @@ private:
std::unique_ptr<TerminalFont> _terminalFont;
std::unique_ptr<KonsolePrintManager> _printManager;
int _semanticHints;
bool _semanticUpDown;
};
}
......
......@@ -239,7 +239,9 @@ void TerminalPainter::drawContents(Character *image,
x += len - 1;
}
if ((lineProperty & LINE_PROMPT_START) != 0 && m_parentDisplay->filterChain()->showUrlHint()) {
if ((lineProperty & LINE_PROMPT_START) != 0
&& ((m_parentDisplay->semanticHints() == Enum::SemanticHintsURL && m_parentDisplay->filterChain()->showUrlHint())
|| m_parentDisplay->semanticHints() == Enum::SemanticHintsAlways)) {
QPen pen(m_parentDisplay->terminalColor()->foregroundColor());
paint.setPen(pen);
paint.drawLine(leftPadding, textY, m_parentDisplay->contentRect().right(), textY);
......
......@@ -483,6 +483,7 @@ void EditProfileDialog::setupGeneralPage(const Profile::Ptr &profile)
connect(_generalUi->initialDirEdit, &QLineEdit::textChanged, this, &Konsole::EditProfileDialog::initialDirChanged);
connect(_generalUi->commandEdit, &QLineEdit::textChanged, this, &Konsole::EditProfileDialog::commandChanged);
connect(_generalUi->environmentEditButton, &QPushButton::clicked, this, &Konsole::EditProfileDialog::showEnvironmentEditor);
connect(_generalUi->semanticUpDown, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::semanticUpDown);
connect(_generalUi->terminalColumnsEntry, QOverload<int>::of(&QSpinBox::valueChanged), this, &Konsole::EditProfileDialog::terminalColumnsEntryChanged);
connect(_generalUi->terminalRowsEntry, QOverload<int>::of(&QSpinBox::valueChanged), this, &Konsole::EditProfileDialog::terminalRowsEntryChanged);
......@@ -492,6 +493,19 @@ void EditProfileDialog::setupGeneralPage(const Profile::Ptr &profile)
});
connect(_generalUi->setAsDefaultButton, &QAbstractButton::toggled, this, &Konsole::EditProfileDialog::updateButtonApply);
const ButtonGroupOptions semanticHints = {
_generalUi->semanticHints, // group
Profile::SemanticHints, // profileProperty
false, // preview
{
// buttons
{_generalUi->semanticHintsNever, Enum::SemanticHintsNever},
{_generalUi->semanticHintsURL, Enum::SemanticHintsURL},
{_generalUi->semanticHintsAlways, Enum::SemanticHintsAlways},
},
};
setupButtonGroup(semanticHints, profile);
}
void EditProfileDialog::showEnvironmentEditor()
......@@ -617,6 +631,11 @@ void EditProfileDialog::startInSameDir(bool sameDir)
updateTempProfileProperty(Profile::StartInCurrentSessionDir, sameDir);
}
void EditProfileDialog::semanticUpDown(bool enable)
{
updateTempProfileProperty(Profile::SemanticUpDown, enable);
}
void EditProfileDialog::initialDirChanged(const QString &dir)
{
updateTempProfileProperty(Profile::Directory, dir);
......
......@@ -120,6 +120,7 @@ private Q_SLOTS:
void initialDirChanged(const QString &dir);
void startInSameDir(bool);
void commandChanged(const QString &command);
void semanticUpDown(bool);
// tab page
void tabTitleFormatChanged(const QString &format);
......
This diff is collapsed.
Supports Markdown
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