mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:37:45 +00:00
LibVT+Terminal: Resize terminal when font changes
When the font is changed in the Terminal application, we now resize the terminal window to accomodate the new font.
This commit is contained in:
parent
9d6198b683
commit
6a19542715
3 changed files with 23 additions and 3 deletions
|
@ -960,8 +960,9 @@ void TerminalWidget::terminal_history_changed()
|
|||
|
||||
void TerminalWidget::terminal_did_resize(u16 columns, u16 rows)
|
||||
{
|
||||
m_pixel_width = (frame_thickness() * 2) + (m_inset * 2) + (columns * font().glyph_width('x')) + m_scrollbar->width();
|
||||
m_pixel_height = (frame_thickness() * 2) + (m_inset * 2) + (rows * (font().glyph_height() + m_line_spacing));
|
||||
auto pixel_size = widget_size_for_font(font());
|
||||
m_pixel_width = pixel_size.width();
|
||||
m_pixel_height = pixel_size.height();
|
||||
|
||||
if (m_automatic_size_policy) {
|
||||
set_fixed_size(m_pixel_width, m_pixel_height);
|
||||
|
@ -1119,3 +1120,17 @@ void TerminalWidget::update_paste_action()
|
|||
{
|
||||
m_paste_action->set_enabled(GUI::Clipboard::the().mime_type().starts_with("text/") && !GUI::Clipboard::the().data().is_empty());
|
||||
}
|
||||
|
||||
Gfx::IntSize TerminalWidget::widget_size_for_font(const Gfx::Font& font) const
|
||||
{
|
||||
return {
|
||||
(frame_thickness() * 2) + (m_inset * 2) + (m_terminal.columns() * font.glyph_width('x')) + m_scrollbar->width(),
|
||||
(frame_thickness() * 2) + (m_inset * 2) + (m_terminal.rows() * (font.glyph_height() + m_line_spacing))
|
||||
};
|
||||
}
|
||||
|
||||
void TerminalWidget::set_font_and_resize_to_fit(const Gfx::Font& font)
|
||||
{
|
||||
set_font(font);
|
||||
resize(widget_size_for_font(font));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue