More resize fixes, still no reflow - holymoly - A tor enabled gopher client written in CHICKEN scheme
 (HTM) git clone git://vernunftzentrum.de/holymoly.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d01fd2d8321c9e99d10ba0038399b5299815cb42
 (DIR) parent 0f875328b6613d07d50036d8ccd2d6d7d0658c19
 (HTM) Author: Christian Kellermann <ckeen@pestilenz.org>
       Date:   Mon, 10 Sep 2018 16:09:47 +0200
       
       More resize fixes, still no reflow
       
       Diffstat:
         holymoly.egg                        |       2 +-
         holymoly.scm                        |      30 +++++++++++++++++++++++++-----
       
       2 files changed, 26 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/holymoly.egg b/holymoly.egg
       @@ -1,5 +1,5 @@
        ((author "Christian Kellermann")
         (license BSD)
         (synopsis "A gopher client using ncurses and supporting SOCKS proxies")
       - (dependencies miscmacros srfi-1 srfi-4 srfi-71 srfi-13 bitstring)
       + (dependencies ioctl miscmacros srfi-1 srfi-4 srfi-71 srfi-13 bitstring)
         (components (program holymoly (linkage static) (files "holymoly.scm" "proxy.scm" "cursor.scm") (link-options "-Wl,-lncursesw"))))
        \ No newline at end of file
 (DIR) diff --git a/holymoly.scm b/holymoly.scm
       @@ -18,6 +18,7 @@
            (chicken process signal)
            (chicken string)
            (chicken tcp)
       +    ioctl
            matchable
            miscmacros
            ncurses
       @@ -38,6 +39,9 @@
        (define gopher-port 70)
        (define index "")
        (define tab (string #\tab))
       +(define rows 0)
       +(define cols 0)
       +(define next-step values)
        
        (define-record entry type title selector host port rest)
        (define-record-printer entry
       @@ -79,7 +83,7 @@
             (lambda (k)
               (let loop ((newp 0))
                (let* ((rows cols (getmaxyx win))
       -                (dlines (take (drop lines newp) (min (- nlines newp) rows))))
       +               (dlines (take (drop lines newp) (min (- nlines newp) rows))))
                   (wclear win)
                   (let draw ((l dlines)
                              (i 0))
       @@ -348,6 +352,20 @@
                     (string-append (type->string (entry-type e))
                                    (entry-selector e))))
        
       +(define (resize-wins _)
       +  (let ((rows+cols (ioctl-winsize (current-output-port))))
       +    (set! rows (car rows+cols))
       +    (set! cols (cadr rows+cols))
       +    (resizeterm rows cols)
       +    (wresize (main-win) (sub1 rows) cols)
       +    (wresize (status-win) 1 cols)
       +    (mvwin (main-win) 0 0)
       +    (mvwin (status-win) (sub1 rows) 0)
       +    (fprintf (current-error-port) "rows ~a cols ~a~%" rows cols)
       +    (clear)
       +    (refresh)
       +    (next-step (current-page))))
       +
        (define (main args)
          (initscr)
          (cbreak)
       @@ -356,12 +374,14 @@
          (clear)
          (refresh)
          (noecho)
       -  (set-signal-handler! signal/winch (lambda (sig) (endwin)(refresh)(clear)))
       +  (set-signal-handler! signal/winch resize-wins)
        
       -  (let ((l c (getmaxyx (stdscr)))
       +  (let ((rows+cols (ioctl-winsize (current-output-port)))
                (start-page (if (null? args) *start-page* (car args))))
       -    (main-win (newwin (sub1 l) c 0 0))
       -    (status-win (newwin 1 c (sub1 l) 0))
       +    (set! rows (car rows+cols))
       +    (set! cols (cadr rows+cols))
       +    (main-win (newwin (sub1 rows) cols 0 0))
       +    (status-win (newwin 1 cols (sub1 rows) 0))
            (new-status "Starting up!")
            (select-entry (uristring->entry start-page))
            (exit 0)))