mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Terminal: Audible vs Visible beep option
This commit is contained in:
parent
9ac95d1867
commit
f8a02d4733
Notes:
sideshowbarker
2024-07-19 13:49:17 +09:00
Author: https://github.com/alexispurslane Commit: https://github.com/SerenityOS/serenity/commit/f8a02d4733e Pull-request: https://github.com/SerenityOS/serenity/pull/153 Reviewed-by: https://github.com/awesomekling
7 changed files with 5995 additions and 9 deletions
1
AK/compile_commands.json
Normal file
1
AK/compile_commands.json
Normal file
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -628,7 +628,10 @@ void Terminal::on_char(byte ch)
|
|||
}
|
||||
return;
|
||||
case '\a':
|
||||
sysbeep();
|
||||
if (m_should_beep)
|
||||
sysbeep();
|
||||
else
|
||||
m_visual_beep_frames = 2;
|
||||
return;
|
||||
case '\t': {
|
||||
for (unsigned i = m_cursor_column; i < columns(); ++i) {
|
||||
|
@ -823,7 +826,8 @@ void Terminal::keydown_event(GKeyEvent& event)
|
|||
}
|
||||
|
||||
void Terminal::paint_event(GPaintEvent& event)
|
||||
{
|
||||
{
|
||||
m_visual_beep_frames--;
|
||||
GFrame::paint_event(event);
|
||||
|
||||
GPainter painter(*this);
|
||||
|
@ -855,9 +859,10 @@ void Terminal::paint_event(GPaintEvent& event)
|
|||
continue;
|
||||
line.dirty = false;
|
||||
bool has_only_one_background_color = line.has_only_one_background_color();
|
||||
if (has_only_one_background_color) {
|
||||
if (m_visual_beep_frames > 0)
|
||||
painter.fill_rect(row_rect(row), Color::Red);
|
||||
else if (has_only_one_background_color)
|
||||
painter.fill_rect(row_rect(row), lookup_color(line.attributes[0].background_color).with_alpha(255 * m_opacity));
|
||||
}
|
||||
for (word column = 0; column < m_columns; ++column) {
|
||||
bool should_reverse_fill_for_cursor = m_cursor_blink_state && m_in_active_window && row == m_cursor_row && column == m_cursor_column;
|
||||
auto& attribute = line.attributes[column];
|
||||
|
@ -877,9 +882,6 @@ void Terminal::paint_event(GPaintEvent& event)
|
|||
auto cell_rect = glyph_rect(m_cursor_row, m_cursor_column).inflated(0, m_line_spacing);
|
||||
painter.draw_rect(cell_rect, lookup_color(line(m_cursor_row).attributes[m_cursor_column].foreground_color));
|
||||
}
|
||||
|
||||
if (m_belling)
|
||||
painter.draw_rect(frame_inner_rect(), Color::Red);
|
||||
}
|
||||
|
||||
void Terminal::set_window_title(const String& title)
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
void apply_size_increments_to_window(GWindow&);
|
||||
|
||||
void set_opacity(float);
|
||||
bool should_beep() { return m_should_beep; };
|
||||
void set_should_beep(bool sb) { m_should_beep = sb; };
|
||||
|
||||
RetainPtr<CConfigFile> config() const { return m_config; }
|
||||
|
||||
|
@ -140,6 +142,9 @@ private:
|
|||
byte m_saved_cursor_column { 0 };
|
||||
bool m_stomp { false };
|
||||
|
||||
bool m_should_beep { false };
|
||||
int m_visual_beep_frames { 0 };
|
||||
|
||||
Attribute m_current_attribute;
|
||||
|
||||
void execute_escape_sequence(byte final);
|
||||
|
|
33
Applications/Terminal/compile_commands.json
Normal file
33
Applications/Terminal/compile_commands.json
Normal file
|
@ -0,0 +1,33 @@
|
|||
[
|
||||
{
|
||||
"arguments": [
|
||||
"i686-pc-serenity-g++",
|
||||
"-c",
|
||||
"-Wextra",
|
||||
"-Wall",
|
||||
"-Wundef",
|
||||
"-Wcast-qual",
|
||||
"-Wwrite-strings",
|
||||
"-Wimplicit-fallthrough",
|
||||
"-Os",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-std=c++17",
|
||||
"-Wno-sized-deallocation",
|
||||
"-fno-sized-deallocation",
|
||||
"-I/home/christopherdumas/serenity",
|
||||
"-I.",
|
||||
"-I/home/christopherdumas/serenity/LibC",
|
||||
"-I/home/christopherdumas/serenity/Servers",
|
||||
"-I/home/christopherdumas/serenity/LibM",
|
||||
"-DSANITIZE_PTRS",
|
||||
"-DDEBUG",
|
||||
"-DUSERLAND",
|
||||
"-o",
|
||||
"Terminal.o",
|
||||
"Terminal.cpp"
|
||||
],
|
||||
"directory": "/home/christopherdumas/serenity/Applications/Terminal",
|
||||
"file": "Terminal.cpp"
|
||||
}
|
||||
]
|
|
@ -106,6 +106,7 @@ int main(int argc, char** argv)
|
|||
terminal.apply_size_increments_to_window(*window);
|
||||
window->show();
|
||||
window->set_icon_path("/res/icons/16x16/app-terminal.png");
|
||||
terminal.set_should_beep(config->read_num_entry("Window", "AudibleBeep", 1) == 1);
|
||||
|
||||
auto* opacity_adjustment_window = new GWindow;
|
||||
opacity_adjustment_window->set_title("Adjust opacity");
|
||||
|
@ -124,6 +125,23 @@ int main(int argc, char** argv)
|
|||
slider->set_range(0, 100);
|
||||
slider->set_value(100);
|
||||
|
||||
auto* beep_choice_window = new GWindow;
|
||||
beep_choice_window->set_title("Terminal beep settings");
|
||||
beep_choice_window->set_rect(50, 50, 200, 100);
|
||||
|
||||
auto* radio_buttons = new GWidget;
|
||||
beep_choice_window->set_main_widget(radio_buttons);
|
||||
radio_buttons->set_fill_with_background_color(true);
|
||||
radio_buttons->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
radio_buttons->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto* sysbell_radio = new GRadioButton("Use (Audible) System Bell", radio_buttons);
|
||||
auto* visbell_radio = new GRadioButton("Use (Visual) Terminal Bell", radio_buttons);
|
||||
sysbell_radio->set_checked(terminal.should_beep());
|
||||
sysbell_radio->on_checked = [&terminal] (const bool res) {
|
||||
terminal.set_should_beep(res);
|
||||
};
|
||||
|
||||
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
|
||||
terminal.set_opacity((float)new_opacity / 255.0);
|
||||
|
||||
|
@ -131,8 +149,11 @@ int main(int argc, char** argv)
|
|||
|
||||
auto app_menu = make<GMenu>("Terminal");
|
||||
app_menu->add_action(GAction::create("Adjust opacity...", [opacity_adjustment_window] (const GAction&) {
|
||||
opacity_adjustment_window->show();
|
||||
}));
|
||||
opacity_adjustment_window->show();
|
||||
}));
|
||||
app_menu->add_action(GAction::create("Change audio output...", [beep_choice_window] (const GAction&) {
|
||||
beep_choice_window->show();
|
||||
}));
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||
dbgprintf("Terminal: Quit menu activated!\n");
|
||||
GApplication::the().quit(0);
|
||||
|
|
2962
Kernel/compile_commands.json
Normal file
2962
Kernel/compile_commands.json
Normal file
File diff suppressed because it is too large
Load diff
2962
compile_commands.json
Normal file
2962
compile_commands.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue