diff options
author | Christopher Dumas <christopherdumas@gmail.com> | 2019-05-25 16:43:15 -0700 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-27 21:40:53 +0200 |
commit | e3f81bce498523cc722524fc795f33e7d5c23c3e (patch) | |
tree | 135f279eb7919a61418a7dd261df2f144d317208 /Applications/Terminal | |
parent | 63486b8438a9d1ec001adc1476a75b276ee308b3 (diff) | |
download | serenity-e3f81bce498523cc722524fc795f33e7d5c23c3e.zip |
IRC client setttings, Terminal settings, more WM settings
Diffstat (limited to 'Applications/Terminal')
-rw-r--r-- | Applications/Terminal/Terminal.cpp | 18 | ||||
-rw-r--r-- | Applications/Terminal/Terminal.h | 7 | ||||
-rw-r--r-- | Applications/Terminal/main.cpp | 10 |
3 files changed, 29 insertions, 6 deletions
diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp index 4f1f23905f..2b987e8b21 100644 --- a/Applications/Terminal/Terminal.cpp +++ b/Applications/Terminal/Terminal.cpp @@ -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) diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h index 97f4ddd3ba..52484080d7 100644 --- a/Applications/Terminal/Terminal.h +++ b/Applications/Terminal/Terminal.h @@ -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; }; diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 0a1eacbb1d..ba0d95f7c5 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -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(); } |