2020-01-18 09:38:21 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2021-05-23 15:47:41 +02:00
|
|
|
|
* Copyright (c) 2021, Daniel Bertalan <dani@danielbertalan.dev>
|
2022-03-04 13:27:47 -07:00
|
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 09:38:21 +01:00
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2019-08-12 17:32:16 +02:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
2020-05-09 13:20:01 +02:00
|
|
|
|
#include <AK/Noncopyable.h>
|
2019-08-12 17:32:16 +02:00
|
|
|
|
#include <AK/Vector.h>
|
2020-07-04 17:22:23 +02:00
|
|
|
|
#include <Kernel/API/KeyCode.h>
|
2021-09-30 13:58:12 +02:00
|
|
|
|
#include <LibVT/CharacterSet.h>
|
2021-05-08 20:37:43 +02:00
|
|
|
|
#include <LibVT/EscapeSequenceParser.h>
|
2019-08-13 12:48:54 +02:00
|
|
|
|
#include <LibVT/Position.h>
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2022-12-04 18:02:33 +00:00
|
|
|
|
# include <AK/DeprecatedString.h>
|
2021-04-16 22:58:51 +03:00
|
|
|
|
# include <LibVT/Attribute.h>
|
|
|
|
|
|
# include <LibVT/Line.h>
|
|
|
|
|
|
#else
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
class VirtualConsole;
|
|
|
|
|
|
}
|
|
|
|
|
|
# include <LibVT/Attribute.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2019-08-12 17:32:16 +02:00
|
|
|
|
namespace VT {
|
|
|
|
|
|
|
2022-05-12 22:52:14 +02:00
|
|
|
|
enum class CursorShape {
|
2021-05-24 09:36:41 +02:00
|
|
|
|
None,
|
2022-05-12 22:52:14 +02:00
|
|
|
|
Block,
|
|
|
|
|
|
Underline,
|
|
|
|
|
|
Bar,
|
2021-05-24 09:36:41 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2021-09-30 11:44:20 +02:00
|
|
|
|
enum CursorKeysMode {
|
|
|
|
|
|
Application,
|
|
|
|
|
|
Cursor,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-08-12 17:32:16 +02:00
|
|
|
|
class TerminalClient {
|
|
|
|
|
|
public:
|
2022-03-04 13:27:47 -07:00
|
|
|
|
virtual ~TerminalClient() = default;
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
|
|
|
|
|
virtual void beep() = 0;
|
2021-11-11 00:55:02 +01:00
|
|
|
|
virtual void set_window_title(StringView) = 0;
|
2020-05-30 22:11:35 +02:00
|
|
|
|
virtual void set_window_progress(int value, int max) = 0;
|
2019-08-12 17:32:16 +02:00
|
|
|
|
virtual void terminal_did_resize(u16 columns, u16 rows) = 0;
|
2021-06-05 16:46:33 +02:00
|
|
|
|
virtual void terminal_history_changed(int delta) = 0;
|
2022-04-01 20:58:27 +03:00
|
|
|
|
virtual void emit(u8 const*, size_t) = 0;
|
2022-05-12 22:52:14 +02:00
|
|
|
|
virtual void set_cursor_shape(CursorShape) = 0;
|
|
|
|
|
|
virtual void set_cursor_blinking(bool) = 0;
|
2019-08-12 17:32:16 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2021-05-08 20:37:43 +02:00
|
|
|
|
class Terminal : public EscapeSequenceExecutor {
|
2019-08-12 17:32:16 +02:00
|
|
|
|
public:
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2019-08-12 17:32:16 +02:00
|
|
|
|
explicit Terminal(TerminalClient&);
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#else
|
|
|
|
|
|
explicit Terminal(Kernel::VirtualConsole&);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~Terminal()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
|
|
|
|
|
bool m_need_full_flush { false };
|
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2019-08-12 17:32:16 +02:00
|
|
|
|
void invalidate_cursor();
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#else
|
|
|
|
|
|
virtual void invalidate_cursor() = 0;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2020-05-16 19:24:24 +02:00
|
|
|
|
void on_input(u8);
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-05-23 15:47:41 +02:00
|
|
|
|
void set_cursor(unsigned row, unsigned column, bool skip_debug = false);
|
2021-04-16 22:58:51 +03:00
|
|
|
|
|
2021-06-05 09:29:49 +02:00
|
|
|
|
void clear_including_history()
|
|
|
|
|
|
{
|
|
|
|
|
|
clear_history();
|
|
|
|
|
|
clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2019-08-12 17:32:16 +02:00
|
|
|
|
void clear();
|
2021-06-05 09:29:49 +02:00
|
|
|
|
void clear_history();
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#else
|
|
|
|
|
|
virtual void clear() = 0;
|
2021-06-05 09:29:49 +02:00
|
|
|
|
virtual void clear_history() = 0;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#endif
|
2020-07-05 23:34:02 +02:00
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2019-08-12 17:32:16 +02:00
|
|
|
|
void set_size(u16 columns, u16 rows);
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#else
|
|
|
|
|
|
virtual void set_size(u16 columns, u16 rows) = 0;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
u16 columns() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_columns;
|
|
|
|
|
|
}
|
2019-08-12 17:32:16 +02:00
|
|
|
|
u16 rows() const { return m_rows; }
|
|
|
|
|
|
|
2021-05-23 15:47:41 +02:00
|
|
|
|
u16 cursor_column() const { return m_current_state.cursor.column; }
|
|
|
|
|
|
u16 cursor_row() const { return m_current_state.cursor.row; }
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2020-05-10 16:59:02 +02:00
|
|
|
|
size_t line_count() const
|
|
|
|
|
|
{
|
2021-05-23 15:47:41 +02:00
|
|
|
|
if (m_use_alternate_screen_buffer)
|
|
|
|
|
|
return m_alternate_screen_buffer.size();
|
|
|
|
|
|
else
|
|
|
|
|
|
return m_history.size() + m_normal_screen_buffer.size();
|
2020-05-10 16:59:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-12 17:32:16 +02:00
|
|
|
|
Line& line(size_t index)
|
|
|
|
|
|
{
|
2021-05-23 15:47:41 +02:00
|
|
|
|
if (m_use_alternate_screen_buffer) {
|
2023-03-06 17:16:25 +01:00
|
|
|
|
return *m_alternate_screen_buffer[index];
|
2021-05-23 15:47:41 +02:00
|
|
|
|
} else {
|
|
|
|
|
|
if (index < m_history.size())
|
2023-03-06 17:16:25 +01:00
|
|
|
|
return *m_history[(m_history_start + index) % m_history.size()];
|
|
|
|
|
|
return *m_normal_screen_buffer[index - m_history.size()];
|
2021-05-23 15:47:41 +02:00
|
|
|
|
}
|
2019-08-12 17:32:16 +02:00
|
|
|
|
}
|
2022-04-01 20:58:27 +03:00
|
|
|
|
Line const& line(size_t index) const
|
2019-08-12 17:32:16 +02:00
|
|
|
|
{
|
2020-11-03 20:02:57 +01:00
|
|
|
|
return const_cast<Terminal*>(this)->line(index);
|
2019-08-12 17:32:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-11 11:54:00 +04:30
|
|
|
|
Line& visible_line(size_t index)
|
|
|
|
|
|
{
|
2023-03-06 17:16:25 +01:00
|
|
|
|
return *active_buffer()[index];
|
2020-05-11 11:54:00 +04:30
|
|
|
|
}
|
2021-05-23 15:47:41 +02:00
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
|
Line const& visible_line(size_t index) const
|
2020-05-11 11:54:00 +04:30
|
|
|
|
{
|
2023-03-06 17:16:25 +01:00
|
|
|
|
return *active_buffer()[index];
|
2020-05-11 11:54:00 +04:30
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-29 17:56:02 +03:30
|
|
|
|
size_t max_history_size() const { return m_max_history_lines; }
|
|
|
|
|
|
void set_max_history_size(size_t value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value == 0) {
|
2021-06-05 16:46:33 +02:00
|
|
|
|
auto previous_size = m_history.size();
|
2020-11-29 17:56:02 +03:30
|
|
|
|
m_max_history_lines = 0;
|
|
|
|
|
|
m_history_start = 0;
|
|
|
|
|
|
m_history.clear();
|
2021-06-05 16:46:33 +02:00
|
|
|
|
m_client.terminal_history_changed(-previous_size);
|
2020-11-29 17:56:02 +03:30
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_max_history_lines > value) {
|
2023-03-06 17:16:25 +01:00
|
|
|
|
Vector<NonnullOwnPtr<Line>> new_history;
|
2020-11-29 17:56:02 +03:30
|
|
|
|
new_history.ensure_capacity(value);
|
|
|
|
|
|
auto existing_line_count = min(m_history.size(), value);
|
|
|
|
|
|
for (size_t i = m_history.size() - existing_line_count; i < m_history.size(); ++i) {
|
|
|
|
|
|
auto j = (m_history_start + i) % m_history.size();
|
|
|
|
|
|
new_history.unchecked_append(move(static_cast<Vector<NonnullOwnPtr<Line>>&>(m_history).at(j)));
|
|
|
|
|
|
}
|
|
|
|
|
|
m_history = move(new_history);
|
|
|
|
|
|
m_history_start = 0;
|
2021-06-05 16:46:33 +02:00
|
|
|
|
m_client.terminal_history_changed(value - existing_line_count);
|
2020-11-29 17:56:02 +03:30
|
|
|
|
}
|
|
|
|
|
|
m_max_history_lines = value;
|
|
|
|
|
|
}
|
2021-06-05 14:13:50 +02:00
|
|
|
|
size_t history_size() const { return m_use_alternate_screen_buffer ? 0 : m_history.size(); }
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#endif
|
2019-08-19 19:07:52 +02:00
|
|
|
|
|
2021-11-11 00:55:02 +01:00
|
|
|
|
void inject_string(StringView);
|
2020-06-13 13:56:39 +03:00
|
|
|
|
void handle_key_press(KeyCode, u32, u8 flags);
|
2019-10-22 22:14:36 +02:00
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2022-04-01 20:58:27 +03:00
|
|
|
|
Attribute attribute_at(Position const&) const;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#endif
|
2020-05-09 16:16:16 +02:00
|
|
|
|
|
2021-05-24 12:01:59 +02:00
|
|
|
|
bool needs_bracketed_paste() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_needs_bracketed_paste;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-06-02 15:36:31 +02:00
|
|
|
|
bool is_within_scroll_region(u16 line) const
|
|
|
|
|
|
{
|
|
|
|
|
|
return line >= m_scroll_region_top && line <= m_scroll_region_bottom;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
protected:
|
2021-05-08 20:37:43 +02:00
|
|
|
|
// ^EscapeSequenceExecutor
|
|
|
|
|
|
virtual void emit_code_point(u32) override;
|
|
|
|
|
|
virtual void execute_control_code(u8) override;
|
|
|
|
|
|
virtual void execute_escape_sequence(Intermediates intermediates, bool ignore, u8 last_byte) override;
|
|
|
|
|
|
virtual void execute_csi_sequence(Parameters parameters, Intermediates intermediates, bool ignore, u8 last_byte) override;
|
|
|
|
|
|
virtual void execute_osc_sequence(OscParameters parameters, u8 last_byte) override;
|
|
|
|
|
|
virtual void dcs_hook(Parameters parameters, Intermediates intermediates, bool ignore, u8 last_byte) override;
|
|
|
|
|
|
virtual void receive_dcs_char(u8 byte) override;
|
|
|
|
|
|
virtual void execute_dcs_sequence() override;
|
2020-05-16 19:47:49 +02:00
|
|
|
|
|
2021-05-23 15:47:41 +02:00
|
|
|
|
struct BufferState {
|
|
|
|
|
|
Attribute attribute;
|
|
|
|
|
|
CursorPosition cursor;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
void carriage_return();
|
2021-06-02 15:36:31 +02:00
|
|
|
|
inline void scroll_up(size_t count = 1);
|
|
|
|
|
|
inline void scroll_down(size_t count = 1);
|
2021-05-17 16:25:35 +02:00
|
|
|
|
void linefeed();
|
2021-06-02 15:36:31 +02:00
|
|
|
|
#ifndef KERNEL
|
|
|
|
|
|
void scroll_up(u16 region_top, u16 region_bottom, size_t count);
|
|
|
|
|
|
void scroll_down(u16 region_top, u16 region_bottom, size_t count);
|
2021-06-05 15:11:45 +02:00
|
|
|
|
void scroll_left(u16 row, u16 column, size_t count);
|
|
|
|
|
|
void scroll_right(u16 row, u16 column, size_t count);
|
2020-05-16 19:21:53 +02:00
|
|
|
|
void put_character_at(unsigned row, unsigned column, u32 ch);
|
2021-06-05 11:12:00 +02:00
|
|
|
|
void clear_in_line(u16 row, u16 first_column, u16 last_column);
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#else
|
2021-06-02 15:36:31 +02:00
|
|
|
|
virtual void scroll_up(u16 region_top, u16 region_bottom, size_t count) = 0;
|
|
|
|
|
|
virtual void scroll_down(u16 region_top, u16 region_bottom, size_t count) = 0;
|
2021-06-05 15:11:45 +02:00
|
|
|
|
virtual void scroll_left(u16 row, u16 column, size_t count) = 0;
|
|
|
|
|
|
virtual void scroll_right(u16 row, u16 column, size_t count) = 0;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
virtual void put_character_at(unsigned row, unsigned column, u32 ch) = 0;
|
2021-06-05 11:12:00 +02:00
|
|
|
|
virtual void clear_in_line(u16 row, u16 first_column, u16 last_column) = 0;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#endif
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void unimplemented_control_code(u8);
|
|
|
|
|
|
void unimplemented_escape_sequence(Intermediates, u8 last_byte);
|
|
|
|
|
|
void unimplemented_csi_sequence(Parameters, Intermediates, u8 last_byte);
|
|
|
|
|
|
void unimplemented_osc_sequence(OscParameters, u8 last_byte);
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-11-11 00:55:02 +01:00
|
|
|
|
void emit_string(StringView);
|
2020-01-25 19:12:08 +01:00
|
|
|
|
|
2021-07-09 12:08:36 +02:00
|
|
|
|
void alter_ansi_mode(bool should_set, Parameters);
|
|
|
|
|
|
void alter_private_mode(bool should_set, Parameters);
|
2020-01-26 14:21:54 +00:00
|
|
|
|
|
2021-02-20 16:07:13 +01:00
|
|
|
|
// CUU – Cursor Up
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void CUU(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// CUD – Cursor Down
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void CUD(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// CUF – Cursor Forward
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void CUF(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// CUB – Cursor Backward
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void CUB(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
2021-05-29 10:48:02 +02:00
|
|
|
|
// CNL - Cursor Next Line
|
|
|
|
|
|
void CNL(Parameters);
|
|
|
|
|
|
|
|
|
|
|
|
// CPL - Cursor Previous Line
|
|
|
|
|
|
void CPL(Parameters);
|
|
|
|
|
|
|
2021-02-20 16:07:13 +01:00
|
|
|
|
// CUP - Cursor Position
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void CUP(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// ED - Erase in Display
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void ED(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// EL - Erase in Line
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void EL(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// SGR – Select Graphic Rendition
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void SGR(Parameters);
|
2021-02-20 16:00:14 +01:00
|
|
|
|
|
|
|
|
|
|
// Save Current Cursor Position
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void SCOSC();
|
2021-02-20 16:00:14 +01:00
|
|
|
|
|
|
|
|
|
|
// Restore Saved Cursor Position
|
2021-05-23 15:47:41 +02:00
|
|
|
|
void SCORC();
|
|
|
|
|
|
|
|
|
|
|
|
// Save Cursor (and other attributes)
|
|
|
|
|
|
void DECSC();
|
|
|
|
|
|
|
|
|
|
|
|
// Restore Cursor (and other attributes)
|
|
|
|
|
|
void DECRC();
|
2021-02-20 16:00:14 +01:00
|
|
|
|
|
2021-02-20 16:07:13 +01:00
|
|
|
|
// DECSTBM – Set Top and Bottom Margins ("Scrolling Region")
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void DECSTBM(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// RM – Reset Mode
|
2021-07-09 12:08:36 +02:00
|
|
|
|
void RM(Parameters);
|
|
|
|
|
|
|
|
|
|
|
|
// DECRST - DEC Private Mode Reset
|
|
|
|
|
|
void DECRST(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// SM – Set Mode
|
2021-07-09 12:08:36 +02:00
|
|
|
|
void SM(Parameters);
|
|
|
|
|
|
|
|
|
|
|
|
// DECSET - Dec Private Mode Set
|
|
|
|
|
|
void DECSET(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// DA - Device Attributes
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void DA(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// HVP – Horizontal and Vertical Position
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void HVP(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// NEL - Next Line
|
2020-01-25 20:01:43 +01:00
|
|
|
|
void NEL();
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// IND - Index (move down)
|
2020-01-25 20:17:50 +01:00
|
|
|
|
void IND();
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
|
|
|
|
|
// RI - Reverse Index (move up)
|
2020-01-25 20:17:50 +01:00
|
|
|
|
void RI();
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
2021-06-05 15:35:14 +02:00
|
|
|
|
// DECBI - Back Index
|
|
|
|
|
|
void DECBI();
|
|
|
|
|
|
|
|
|
|
|
|
// DECFI - Forward Index
|
|
|
|
|
|
void DECFI();
|
|
|
|
|
|
|
2021-02-20 16:07:13 +01:00
|
|
|
|
// DSR - Device Status Reports
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void DSR(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
2021-05-24 09:36:41 +02:00
|
|
|
|
// DECSCUSR - Set Cursor Style
|
|
|
|
|
|
void DECSCUSR(Parameters);
|
|
|
|
|
|
|
2021-02-20 16:07:13 +01:00
|
|
|
|
// ICH - Insert Character
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void ICH(Parameters);
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-02-20 16:12:23 +01:00
|
|
|
|
// SU - Scroll Up (called "Pan Down" in VT510)
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void SU(Parameters);
|
2021-02-20 16:12:23 +01:00
|
|
|
|
|
|
|
|
|
|
// SD - Scroll Down (called "Pan Up" in VT510)
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void SD(Parameters);
|
2021-02-20 16:12:23 +01:00
|
|
|
|
|
2021-02-20 16:35:14 +01:00
|
|
|
|
// IL - Insert Line
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void IL(Parameters);
|
2021-06-02 15:36:31 +02:00
|
|
|
|
|
2021-02-20 16:35:14 +01:00
|
|
|
|
// DCH - Delete Character
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void DCH(Parameters);
|
2021-02-20 16:35:14 +01:00
|
|
|
|
|
2021-06-02 15:36:31 +02:00
|
|
|
|
// DL - Delete Line
|
|
|
|
|
|
void DL(Parameters);
|
|
|
|
|
|
|
2021-02-20 16:35:14 +01:00
|
|
|
|
// CHA - Cursor Horizontal Absolute
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void CHA(Parameters);
|
2021-02-20 16:35:14 +01:00
|
|
|
|
|
|
|
|
|
|
// REP - Repeat
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void REP(Parameters);
|
2021-02-20 16:35:14 +01:00
|
|
|
|
|
2021-05-29 10:48:02 +02:00
|
|
|
|
// VPA - Line Position Absolute
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void VPA(Parameters);
|
2021-02-20 16:35:14 +01:00
|
|
|
|
|
2021-05-29 10:48:02 +02:00
|
|
|
|
// VPR - Line Position Relative
|
|
|
|
|
|
void VPR(Parameters);
|
|
|
|
|
|
|
|
|
|
|
|
// HPA - Character Position Absolute
|
|
|
|
|
|
void HPA(Parameters);
|
|
|
|
|
|
|
|
|
|
|
|
// HPR - Character Position Relative
|
|
|
|
|
|
void HPR(Parameters);
|
|
|
|
|
|
|
2021-02-20 16:35:14 +01:00
|
|
|
|
// ECH - Erase Character
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void ECH(Parameters);
|
2021-02-20 16:35:14 +01:00
|
|
|
|
|
2021-02-20 16:07:13 +01:00
|
|
|
|
// FIXME: Find the right names for these.
|
2021-05-08 20:37:43 +02:00
|
|
|
|
void XTERM_WM(Parameters);
|
2021-02-20 16:07:13 +01:00
|
|
|
|
|
2021-06-09 21:50:44 +02:00
|
|
|
|
// DECIC - Insert Column
|
|
|
|
|
|
void DECIC(Parameters);
|
|
|
|
|
|
|
|
|
|
|
|
// DECDC - Delete Column
|
|
|
|
|
|
void DECDC(Parameters);
|
|
|
|
|
|
|
2021-09-30 11:43:17 +02:00
|
|
|
|
// DECPNM - Set numeric keypad mode
|
|
|
|
|
|
void DECPNM();
|
|
|
|
|
|
|
|
|
|
|
|
// DECPAM - Set application keypad mode
|
|
|
|
|
|
void DECPAM();
|
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2019-08-12 17:32:16 +02:00
|
|
|
|
TerminalClient& m_client;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#else
|
|
|
|
|
|
Kernel::VirtualConsole& m_client;
|
|
|
|
|
|
#endif
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-05-08 20:37:43 +02:00
|
|
|
|
EscapeSequenceParser m_parser;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2020-09-09 19:06:57 -04:00
|
|
|
|
size_t m_history_start = 0;
|
2023-03-06 17:16:25 +01:00
|
|
|
|
Vector<NonnullOwnPtr<Line>> m_history;
|
2020-09-09 19:06:57 -04:00
|
|
|
|
void add_line_to_history(NonnullOwnPtr<Line>&& line)
|
|
|
|
|
|
{
|
2020-11-29 17:56:02 +03:30
|
|
|
|
if (max_history_size() == 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2021-12-28 09:44:30 -06:00
|
|
|
|
// If m_history can expand, add the new line to the end of the list.
|
|
|
|
|
|
// If there is an overflow wrap, the end is at the index before the start.
|
2020-09-09 19:06:57 -04:00
|
|
|
|
if (m_history.size() < max_history_size()) {
|
2021-12-28 09:44:30 -06:00
|
|
|
|
if (m_history_start == 0)
|
|
|
|
|
|
m_history.append(move(line));
|
|
|
|
|
|
else
|
|
|
|
|
|
m_history.insert(m_history_start - 1, move(line));
|
|
|
|
|
|
|
2020-09-09 19:06:57 -04:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-03-06 17:16:25 +01:00
|
|
|
|
m_history[m_history_start] = move(line);
|
2020-09-09 19:06:57 -04:00
|
|
|
|
m_history_start = (m_history_start + 1) % m_history.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-06 17:16:25 +01:00
|
|
|
|
Vector<NonnullOwnPtr<Line>>& active_buffer() { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; };
|
|
|
|
|
|
Vector<NonnullOwnPtr<Line>> const& active_buffer() const { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; };
|
|
|
|
|
|
Vector<NonnullOwnPtr<Line>> m_normal_screen_buffer;
|
|
|
|
|
|
Vector<NonnullOwnPtr<Line>> m_alternate_screen_buffer;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#endif
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-05-23 15:47:41 +02:00
|
|
|
|
bool m_use_alternate_screen_buffer { false };
|
|
|
|
|
|
|
2020-02-25 14:49:47 +01:00
|
|
|
|
size_t m_scroll_region_top { 0 };
|
|
|
|
|
|
size_t m_scroll_region_bottom { 0 };
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2020-01-15 21:13:54 -06:00
|
|
|
|
u16 m_columns { 1 };
|
|
|
|
|
|
u16 m_rows { 1 };
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2021-05-23 15:47:41 +02:00
|
|
|
|
BufferState m_current_state;
|
|
|
|
|
|
BufferState m_normal_saved_state;
|
|
|
|
|
|
BufferState m_alternate_saved_state;
|
|
|
|
|
|
|
|
|
|
|
|
// Separate from *_saved_state: some escape sequences only save/restore the cursor position,
|
|
|
|
|
|
// while others impact the text attributes and other state too.
|
|
|
|
|
|
CursorPosition m_saved_cursor_position;
|
|
|
|
|
|
|
2019-08-12 17:32:16 +02:00
|
|
|
|
bool m_swallow_current { false };
|
|
|
|
|
|
bool m_stomp { false };
|
|
|
|
|
|
|
2022-05-12 22:52:14 +02:00
|
|
|
|
CursorShape m_cursor_shape { VT::CursorShape::Block };
|
|
|
|
|
|
CursorShape m_saved_cursor_shape { VT::CursorShape::Block };
|
|
|
|
|
|
bool m_cursor_is_blinking_set { true };
|
2021-05-24 09:36:41 +02:00
|
|
|
|
|
2021-05-24 12:01:59 +02:00
|
|
|
|
bool m_needs_bracketed_paste { false };
|
|
|
|
|
|
|
2019-08-12 17:32:16 +02:00
|
|
|
|
Attribute m_current_attribute;
|
2021-05-08 20:37:43 +02:00
|
|
|
|
Attribute m_saved_attribute;
|
2019-08-12 17:32:16 +02:00
|
|
|
|
|
2022-07-14 05:53:13 +03:00
|
|
|
|
#ifndef KERNEL
|
2022-12-04 18:02:33 +00:00
|
|
|
|
DeprecatedString m_current_window_title;
|
|
|
|
|
|
Vector<DeprecatedString> m_title_stack;
|
2022-02-15 22:46:49 +02:00
|
|
|
|
#endif
|
2021-05-24 10:40:00 +02:00
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#ifndef KERNEL
|
2020-05-09 16:16:16 +02:00
|
|
|
|
u32 m_next_href_id { 0 };
|
2021-04-16 22:58:51 +03:00
|
|
|
|
#endif
|
2020-05-09 16:16:16 +02:00
|
|
|
|
|
2019-08-12 17:32:16 +02:00
|
|
|
|
Vector<bool> m_horizontal_tabs;
|
2020-08-05 16:31:20 -04:00
|
|
|
|
u32 m_last_code_point { 0 };
|
2020-11-29 17:56:02 +03:30
|
|
|
|
size_t m_max_history_lines { 1024 };
|
2021-06-19 18:17:18 +04:30
|
|
|
|
|
|
|
|
|
|
Optional<u16> m_column_before_carriage_return;
|
|
|
|
|
|
bool m_controls_are_logically_generated { false };
|
2021-09-30 11:44:20 +02:00
|
|
|
|
CursorKeysMode m_cursor_keys_mode { Cursor };
|
2021-09-30 13:58:12 +02:00
|
|
|
|
|
|
|
|
|
|
CharacterSetTranslator m_character_set_translator {};
|
|
|
|
|
|
size_t m_active_working_set_index { 0 };
|
|
|
|
|
|
CharacterSet m_working_sets[4] { Iso_8859_1 };
|
2019-08-12 17:32:16 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|