Bladeren bron

Terminal: Add some inset and line spacing.

This is starting to feel vaguely usable! :^)
Andreas Kling 6 jaren geleden
bovenliggende
commit
d14ec951ea
2 gewijzigde bestanden met toevoegingen van 7 en 5 verwijderingen
  1. 4 5
      Terminal/Terminal.cpp
  2. 3 0
      Terminal/Terminal.h

+ 4 - 5
Terminal/Terminal.cpp

@@ -10,8 +10,8 @@ void Terminal::create_window()
 {
     auto& font = Font::defaultFont();
 
-    m_pixel_width = m_columns * font.glyphWidth();
-    m_pixel_height = m_rows * font.glyphHeight();
+    m_pixel_width = m_columns * font.glyphWidth() + m_inset * 2;
+    m_pixel_height = (m_rows * (font.glyphHeight() + m_line_spacing)) + (m_inset * 2);
 
     GUI_CreateWindowParameters params;
     params.rect = { { 300, 300 }, { m_pixel_width, m_pixel_height } };
@@ -161,7 +161,6 @@ void Terminal::escape$m(const Vector<unsigned>& params)
         case 36:
         case 37:
             // Foreground color
-            dbgprintf("foreground = %d\n", param - 30);
             m_current_attribute.foreground_color = param - 30;
             break;
         case 40:
@@ -393,12 +392,12 @@ void Terminal::paint()
     Painter painter(*m_backing);
 
     for (word row = 0; row < m_rows; ++row) {
-        int y = row * font.glyphHeight();
+        int y = row * (font.glyphHeight() + m_line_spacing);
         for (word column = 0; column < m_columns; ++column) {
             char ch = m_buffer[(row * m_columns) + (column)];
             auto& attribute = m_attributes[(row * m_columns) + (column)];
             int x = column * font.glyphWidth();
-            Rect glyph_rect { x + 2, y + 2, font.glyphWidth(), font.glyphHeight() };
+            Rect glyph_rect { x + m_inset, y + m_inset, font.glyphWidth(), font.glyphHeight() + m_line_spacing};
             auto glyph_background = ansi_color(attribute.background_color);
             painter.fill_rect(glyph_rect, glyph_background);
             if (ch == ' ')

+ 3 - 0
Terminal/Terminal.h

@@ -80,4 +80,7 @@ private:
 
     int m_pixel_width { 0 };
     int m_pixel_height { 0 };
+
+    int m_inset { 2 };
+    int m_line_spacing { 4 };
 };