mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
IRC client setttings, Terminal settings, more WM settings
This commit is contained in:
parent
63486b8438
commit
e3f81bce49
13 changed files with 89 additions and 53 deletions
|
@ -17,21 +17,30 @@
|
|||
|
||||
//#define TERMINAL_DEBUG
|
||||
|
||||
Terminal::Terminal(int ptm_fd)
|
||||
Terminal::Terminal(int ptm_fd, RetainPtr<CConfigFile> config)
|
||||
: m_ptm_fd(ptm_fd)
|
||||
, m_notifier(ptm_fd, CNotifier::Read)
|
||||
, m_config(config)
|
||||
{
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
|
||||
m_cursor_blink_timer.set_interval(500);
|
||||
dbgprintf("Terminal: Load config file from %s\n", m_config->file_name().characters());
|
||||
m_cursor_blink_timer.set_interval(m_config->read_num_entry("Text",
|
||||
"CursorBlinkInterval",
|
||||
500));
|
||||
m_cursor_blink_timer.on_timeout = [this] {
|
||||
m_cursor_blink_state = !m_cursor_blink_state;
|
||||
update_cursor();
|
||||
};
|
||||
|
||||
set_font(Font::default_fixed_width_font());
|
||||
auto font_entry = m_config->read_entry("Text", "Font", "default");
|
||||
if (font_entry == "default")
|
||||
set_font(Font::default_fixed_width_font());
|
||||
else
|
||||
set_font(Font::load_from_file(font_entry));
|
||||
|
||||
m_notifier.on_ready_to_read = [this]{
|
||||
byte buffer[BUFSIZ];
|
||||
ssize_t nread = read(m_ptm_fd, buffer, sizeof(buffer));
|
||||
|
@ -53,7 +62,8 @@ Terminal::Terminal(int ptm_fd)
|
|||
|
||||
m_line_height = font().glyph_height() + m_line_spacing;
|
||||
|
||||
set_size(80, 25);
|
||||
set_size(m_config->read_num_entry("Window", "Width", 80),
|
||||
m_config->read_num_entry("Window", "Height", 25));
|
||||
}
|
||||
|
||||
Terminal::Line::Line(word columns)
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
#include <LibGUI/GFrame.h>
|
||||
#include <LibCore/CNotifier.h>
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibCore/CConfigFile.h>
|
||||
|
||||
class Font;
|
||||
|
||||
class Terminal final : public GFrame {
|
||||
public:
|
||||
explicit Terminal(int ptm_fd);
|
||||
explicit Terminal(int ptm_fd, RetainPtr<CConfigFile> config);
|
||||
virtual ~Terminal() override;
|
||||
|
||||
void create_window();
|
||||
|
@ -26,6 +27,8 @@ public:
|
|||
|
||||
void set_opacity(float);
|
||||
|
||||
RetainPtr<CConfigFile> config() const { return m_config; }
|
||||
|
||||
private:
|
||||
typedef Vector<unsigned, 4> ParamVector;
|
||||
|
||||
|
@ -42,6 +45,7 @@ private:
|
|||
void invalidate_cursor();
|
||||
void set_window_title(const String&);
|
||||
|
||||
|
||||
void inject_string(const String&);
|
||||
void unimplemented_escape();
|
||||
void unimplemented_xterm_escape();
|
||||
|
@ -165,4 +169,5 @@ private:
|
|||
int m_glyph_width { 0 };
|
||||
|
||||
CTimer m_cursor_blink_timer;
|
||||
RetainPtr<CConfigFile> m_config;
|
||||
};
|
||||
|
|
|
@ -94,7 +94,8 @@ int main(int argc, char** argv)
|
|||
window->set_double_buffering_enabled(false);
|
||||
window->set_should_exit_event_loop_on_close(true);
|
||||
|
||||
Terminal terminal(ptm_fd);
|
||||
RetainPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
|
||||
Terminal terminal(ptm_fd, config);
|
||||
window->set_has_alpha_channel(true);
|
||||
window->set_main_widget(&terminal);
|
||||
window->move_to(300, 300);
|
||||
|
@ -119,6 +120,9 @@ int main(int argc, char** argv)
|
|||
slider->set_range(0, 100);
|
||||
slider->set_value(100);
|
||||
|
||||
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
|
||||
terminal.set_opacity((float)new_opacity / 255.0);
|
||||
|
||||
auto menubar = make<GMenuBar>();
|
||||
|
||||
auto app_menu = make<GMenu>("Terminal");
|
||||
|
@ -136,6 +140,9 @@ int main(int argc, char** argv)
|
|||
GFontDatabase::the().for_each_fixed_width_font([&] (const String& font_name) {
|
||||
font_menu->add_action(GAction::create(font_name, [&terminal] (const GAction& action) {
|
||||
terminal.set_font(GFontDatabase::the().get_by_name(action.text()));
|
||||
auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
|
||||
terminal.config()->write_entry("Text", "Font", metadata.path);
|
||||
terminal.config()->sync();
|
||||
terminal.force_repaint();
|
||||
}));
|
||||
});
|
||||
|
@ -149,5 +156,6 @@ int main(int argc, char** argv)
|
|||
|
||||
app.set_menubar(move(menubar));
|
||||
|
||||
config->sync();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue