summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVT
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-05-15 14:58:24 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-16 11:50:56 +0200
commite0b6cfec1ab1092148e04e1bd8aa67aef731483b (patch)
tree0ddb516e630694d57e88673b0cad76db02c68fbd /Userland/Libraries/LibVT
parentbe519022c3326f7d5cec964b6d3b72d419b0f522 (diff)
downloadserenity-e0b6cfec1ab1092148e04e1bd8aa67aef731483b.zip
LibVT: fix SM/RM not respecting private markers
Since we now store intermediate characters separately, the intermediates should be checked for the presence of the '?' DEC private marker, not the first parameter.
Diffstat (limited to 'Userland/Libraries/LibVT')
-rw-r--r--Userland/Libraries/LibVT/Terminal.cpp84
-rw-r--r--Userland/Libraries/LibVT/Terminal.h6
2 files changed, 40 insertions, 50 deletions
diff --git a/Userland/Libraries/LibVT/Terminal.cpp b/Userland/Libraries/LibVT/Terminal.cpp
index e06f57c1ed..6563b3cb17 100644
--- a/Userland/Libraries/LibVT/Terminal.cpp
+++ b/Userland/Libraries/LibVT/Terminal.cpp
@@ -39,62 +39,52 @@ void Terminal::clear_including_history()
m_client.terminal_history_changed();
}
-void Terminal::alter_mode(bool should_set, bool question_param, Parameters params)
+void Terminal::alter_mode(bool should_set, Parameters params, Intermediates intermediates)
{
- int mode = 2;
- if (params.size() > 0) {
- mode = params[0];
- }
- if (!question_param) {
- switch (mode) {
- // FIXME: implement *something* for this
- default:
- dbgln("Terminal::alter_mode: Unimplemented mode {} (set={})", mode, should_set);
- break;
+ if (intermediates.size() > 0 && intermediates[0] == '?') {
+ for (auto mode : params) {
+ switch (mode) {
+ case 3: {
+ // 80/132-column mode (DECCOLM)
+ unsigned new_columns = should_set ? 80 : 132;
+ dbgln_if(TERMINAL_DEBUG, "Setting {}-column mode", new_columns);
+ set_size(new_columns, rows());
+ clear();
+ break;
+ }
+ case 25:
+ // Hide cursor command, but doesn't need to be run (for now, because
+ // we don't do inverse control codes anyways)
+ if (should_set)
+ dbgln("Terminal: Hide Cursor escapecode received. Not needed: ignored.");
+ else
+ dbgln("Terminal: Show Cursor escapecode received. Not needed: ignored.");
+ break;
+ default:
+ dbgln("Terminal::alter_mode: Unimplemented private mode {}", mode);
+ break;
+ }
}
} else {
- switch (mode) {
- case 3: {
- // 80/132-column mode (DECCOLM)
- unsigned new_columns = should_set ? 80 : 132;
- dbgln_if(TERMINAL_DEBUG, "Setting {}-column mode", new_columns);
- set_size(new_columns, rows());
- clear();
- break;
- }
- case 25:
- // Hide cursor command, but doesn't need to be run (for now, because
- // we don't do inverse control codes anyways)
- if (should_set)
- dbgln("Terminal: Hide Cursor escapecode received. Not needed: ignored.");
- else
- dbgln("Terminal: Show Cursor escapecode received. Not needed: ignored.");
- break;
- default:
- dbgln("Terminal::alter_mode: Unimplemented private mode {}", mode);
- break;
+ for (auto mode : params) {
+ switch (mode) {
+ // FIXME: implement *something* for this
+ default:
+ dbgln("Terminal::alter_mode: Unimplemented mode {} (set={})", mode, should_set);
+ break;
+ }
}
}
}
-void Terminal::RM(Parameters params)
+void Terminal::RM(Parameters params, Intermediates intermediates)
{
- bool question_param = false;
- if (params.size() > 0 && params[0] == '?') {
- question_param = true;
- params = params.slice(1);
- }
- alter_mode(true, question_param, params);
+ alter_mode(true, params, intermediates);
}
-void Terminal::SM(Parameters params)
+void Terminal::SM(Parameters params, Intermediates intermediates)
{
- bool question_param = false;
- if (params.size() > 0 && params[0] == '?') {
- question_param = true;
- params = params.slice(1);
- }
- alter_mode(false, question_param, params);
+ alter_mode(false, params, intermediates);
}
void Terminal::SGR(Parameters params)
@@ -804,10 +794,10 @@ void Terminal::execute_csi_sequence(Parameters parameters, Intermediates interme
DECSTBM(parameters);
break;
case 'l':
- RM(parameters);
+ RM(parameters, intermediates);
break;
case 'h':
- SM(parameters);
+ SM(parameters, intermediates);
break;
case 'c':
DA(parameters);
diff --git a/Userland/Libraries/LibVT/Terminal.h b/Userland/Libraries/LibVT/Terminal.h
index bf23e7cc9b..7198059654 100644
--- a/Userland/Libraries/LibVT/Terminal.h
+++ b/Userland/Libraries/LibVT/Terminal.h
@@ -133,7 +133,7 @@ private:
void emit_string(const StringView&);
- void alter_mode(bool should_set, bool question_param, Parameters);
+ void alter_mode(bool should_set, Parameters, Intermediates);
// CUU – Cursor Up
void CUU(Parameters);
@@ -169,10 +169,10 @@ private:
void DECSTBM(Parameters);
// RM – Reset Mode
- void RM(Parameters);
+ void RM(Parameters, Intermediates);
// SM – Set Mode
- void SM(Parameters);
+ void SM(Parameters, Intermediates);
// DA - Device Attributes
void DA(Parameters);