Le dim. 3 févr. 2019 à 22:22, Mike Gran <[email protected]> a écrit :
> On Sun, Feb 03, 2019 at 02:07:00PM +0100, Amirouche Boubekki wrote: > > Hello, > > > > > > I have a strange bug in my terminal-based editor. > > The code can be found at https://framagit.org/a-guile-mind/zk > > > > To install you will need guile-bytestructures and guile-pfds. > > > > Then: > > > > git clone https://framagit.org/a-guile-mind/zk > > cd zk > > make dev > > > > You will also need to change the following line: > > > > https://framagit.org/a-guile-mind/zk/blob/master/zk/termbox.scm#L174 > > > > Then you can type: > > > > make run > > > > This will clear the terminal and display the content of 'zk.scm'. > > > > If you type 'enter' key, it should add a newline at the start > > of the buffer. It does, but rendering has glitches. If you resize > > the window it will remove the glitches. > > I did build and run your program, passing the output through teseq to > see which control codes it was writing out. As far as I can tell, the > glitch you are seeing is in your code, and it not a mysterious > console bug. > > Teseq tells me that after I hit carriage return, your program moves to > the top-left corner, does a line-feed (pushing everything down and > putting the cursor in line 2, column 1) prints some spaces over all > the characters in line 2, jumps to column 16, and then writes "ice-9 > match)))" > > It works after resizing because after resizing, you move to 1,1 and then > emit an "erase in page". > > To use teseq, I typed "script" which starts a console session that gets > saved in the "typescript" file, and then I called "teseq typescript" on > the output. > > Regards, > Mike Gran > > Thanks a lot. I was looking for something like teseq. I found the bug, here is the diff: diff --git a/zk.scm b/zk.scm index 76ae863..ad8aa5c 100644 --- a/zk.scm +++ b/zk.scm @@ -334,7 +334,8 @@ main loop." (define (%%container-render-char x0 y0 view-x max-x) (lambda (x y char) - (tb-change-cell (+ x0 x) (+ y0 y) char TB-WHITE TB-DEFAULT))) + (unless (equal? char (char->integer #\newline)) + (tb-change-cell (+ x0 x) (+ y0 y) char TB-WHITE TB-DEFAULT)))) (define (%%container-render buffer x0 y0 view-x view-y width height) (let* ((head (buffer-take-lines buffer (+ view-y height))) I was sending #\newline char as integer to tb-change-cell which was not expected, and create some kind of panic in the escape sequences sent to terminal. Indeed the newline end up in teseq as a line feed (LF). I endup finding the bug by comparing line by line the teseq output of azul.scm and zk.scm. Thanks again!
