Bladeren bron

Make the widgets code build on macOS.

Funny, I haven't looked at this code in a few weeks and there's so much to change!
Andreas Kling 6 jaren geleden
bovenliggende
commit
dd502bb54e
3 gewijzigde bestanden met toevoegingen van 19 en 13 verwijderingen
  1. 4 4
      Widgets/AbstractScreen.h
  2. 8 8
      Widgets/MsgBox.cpp
  3. 7 1
      Widgets/TerminalWidget.cpp

+ 4 - 4
Widgets/AbstractScreen.h

@@ -7,8 +7,8 @@ class AbstractScreen : public Object {
 public:
     virtual ~AbstractScreen();
 
-    unsigned width() const { return m_width; }
-    unsigned height() const { return m_height; }
+    int width() const { return m_width; }
+    int height() const { return m_height; }
 
     static AbstractScreen& the();
 
@@ -18,7 +18,7 @@ protected:
     AbstractScreen(unsigned width, unsigned height);
 
 private:
-    unsigned m_width { 0 };
-    unsigned m_height { 0 };
+    int m_width { 0 };
+    int m_height { 0 };
 };
 

+ 8 - 8
Widgets/MsgBox.cpp

@@ -10,14 +10,14 @@ void MsgBox(Window* owner, String&& text)
     Font& font = Font::defaultFont();
     auto screenRect = AbstractScreen::the().rect();
 
-    unsigned textWidth = text.length() * font.glyphWidth() + 8;
-    unsigned textHeight = font.glyphHeight() + 8;
-    unsigned horizontalPadding = 16;
-    unsigned verticalPadding = 16;
-    unsigned buttonWidth = 60;
-    unsigned buttonHeight = 20;
-    unsigned windowWidth = textWidth + horizontalPadding * 2;
-    unsigned windowHeight = textHeight + buttonHeight + verticalPadding * 3;
+    int textWidth = text.length() * font.glyphWidth() + 8;
+    int textHeight = font.glyphHeight() + 8;
+    int horizontalPadding = 16;
+    int verticalPadding = 16;
+    int buttonWidth = 60;
+    int buttonHeight = 20;
+    int windowWidth = textWidth + horizontalPadding * 2;
+    int windowHeight = textHeight + buttonHeight + verticalPadding * 3;
 
     Rect windowRect(
         screenRect.center().x() - windowWidth / 2,

+ 7 - 1
Widgets/TerminalWidget.cpp

@@ -14,7 +14,7 @@ TerminalWidget::TerminalWidget(Widget* parent)
 {
     g_tw = this;
 
-    setWindowRelativeRect({ 0, 0, (columns() * font().glyphWidth()) + 4, (rows() * font().glyphHeight()) + 4 });
+    setWindowRelativeRect({ 0, 0, int(columns() * font().glyphWidth()) + 4, int(rows() * font().glyphHeight()) + 4 });
 
     printf("rekt: %d x %d\n", width(), height());
     m_screen = new CharacterWithAttributes[rows() * columns()]; 
@@ -24,7 +24,13 @@ TerminalWidget::TerminalWidget(Widget* parent)
             at(row, column).attribute = 0x07;
         }
     }
+
+#if __APPLE__
+    g_fd = posix_openpt(O_RDWR);
+#else
     g_fd = getpt();
+#endif
+
     grantpt(g_fd);
     unlockpt(g_fd);
     char buf[1024];