about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-01-08 22:08:27 +0100
committerbptato <nincsnevem662@gmail.com>2023-01-08 22:08:27 +0100
commit970ebdaba81e042a805e1b8f6d22451f4660ad8f (patch)
tree19362c498c9e2f9a1a98463b04421d0544ae12ca /src/io
parent4821ab4b408d02a08ac2eda14e99259d672b91ea (diff)
downloadchawan-970ebdaba81e042a805e1b8f6d22451f4660ad8f.tar.gz
io/window: use all available columns
should always work now
Diffstat (limited to 'src/io')
-rw-r--r--src/io/window.nim12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/io/window.nim b/src/io/window.nim
index 95da9e70..278fc3fb 100644
--- a/src/io/window.nim
+++ b/src/io/window.nim
@@ -15,8 +15,8 @@ type
     height_px*: int
 
 proc getWindowAttributes*(tty: File): WindowAttributes =
-  if tty.isatty():
-    when defined(posix):
+  when defined(posix):
+    if tty.isatty():
       var win: IOctl_WinSize
       if ioctl(cint(getOsFileHandle(tty)), TIOCGWINSZ, addr win) != -1:
         var cols = win.ws_col
@@ -25,8 +25,10 @@ proc getWindowAttributes*(tty: File): WindowAttributes =
           cols = 80
         if rows == 0:
           rows = 24
-        # some terminals don't like it when we fill the last cell. #TODO make this optional
-        result.width = int(cols) - 1
+        # Filling the last row without raw mode breaks things. However,
+        # not supporting Windows means we can always have raw mode, so we can
+        # use all available columns.
+        result.width = int(cols)
         result.height = int(rows)
         result.ppc = int(win.ws_xpixel) div result.width
         result.ppl = int(win.ws_ypixel) div result.height
@@ -40,7 +42,7 @@ proc getWindowAttributes*(tty: File): WindowAttributes =
         result.height_px = result.height * result.ppl
         result.cell_ratio = result.ppl / result.ppc
         return
-  #fail
+  # for Windows. unused.
   result.width = terminalWidth() - 1
   result.height = terminalHeight()
   if result.height == 0: