qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs qe.c qe.h tty.c unix.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c qe.h tty.c unix.c
Date: Mon, 17 Apr 2017 19:01:22 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/04/17 19:01:21

Modified files:
        .              : qe.c qe.h tty.c unix.c 

Log message:
        display: improve automatic redisplay upon terminal window resize
        - signal and detect asynchronous redisplay signal from SIGWINCH

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.270&r2=1.271
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.252&r2=1.253
http://cvs.savannah.gnu.org/viewcvs/qemacs/tty.c?cvsroot=qemacs&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/qemacs/unix.c?cvsroot=qemacs&r1=1.10&r2=1.11

Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.270
retrieving revision 1.271
diff -u -b -r1.270 -r1.271
--- qe.c        17 Apr 2017 18:14:15 -0000      1.270
+++ qe.c        17 Apr 2017 23:01:21 -0000      1.271
@@ -7384,10 +7384,10 @@
             } else {
                 /* NOTE: to ensure that no rounding errors are made,
                    we resize the absolute coordinates */
-                e->x1 = (e->x1 * width) / qs->width;
-                e->x2 = (e->x2 * width) / qs->width;
-                e->y1 = (e->y1 * content_height) / qs->content_height;
-                e->y2 = (e->y2 * content_height) / qs->content_height;
+                e->x1 = (e->x1 * width + qs->width / 2) / qs->width;
+                e->x2 = (e->x2 * width + qs->width / 2) / qs->width;
+                e->y1 = (e->y1 * content_height + qs->content_height / 2) / 
qs->content_height;
+                e->y2 = (e->y2 * content_height + qs->content_height / 2) / 
qs->content_height;
             }
         }
 

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -b -r1.252 -r1.253
--- qe.h        17 Apr 2017 18:14:15 -0000      1.252
+++ qe.h        17 Apr 2017 23:01:21 -0000      1.253
@@ -153,6 +153,7 @@
 int set_pid_handler(int pid,
                     void (*cb)(void *opaque, int status), void *opaque);
 void url_exit(void);
+void url_redisplay(void);
 void register_bottom_half(void (*cb)(void *opaque), void *opaque);
 void unregister_bottom_half(void (*cb)(void *opaque), void *opaque);
 

Index: tty.c
===================================================================
RCS file: /sources/qemacs/qemacs/tty.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- tty.c       14 Apr 2017 06:59:17 -0000      1.79
+++ tty.c       17 Apr 2017 23:01:21 -0000      1.80
@@ -144,6 +144,7 @@
     unsigned int comb_cache[COMB_CACHE_SIZE];
 } TTYState;
 
+static void tty_term_invalidate(QEditScreen *s);
 static void tty_resize(int sig);
 static void tty_term_exit(void);
 static void tty_read_handler(void *opaque);
@@ -254,11 +255,11 @@
     tcgetattr(fileno(s->STDIN), &tty);
     ts->oldtty = tty;
 
-    tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
-                     |INLCR|IGNCR|ICRNL|IXON);
+    tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
+                     INLCR | IGNCR | ICRNL | IXON);
     tty.c_oflag |= OPOST;
-    tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG);
-    tty.c_cflag &= ~(CSIZE|PARENB);
+    tty.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
+    tty.c_cflag &= ~(CSIZE | PARENB);
     tty.c_cflag |= CS8;
     tty.c_cc[VMIN] = 1;
     tty.c_cc[VTIME] = 0;
@@ -332,7 +333,7 @@
 
     set_read_handler(fileno(s->STDIN), tty_read_handler, s);
 
-    tty_resize(0);
+    tty_term_invalidate(s);
 
     if (ts->term_flags & KBS_CONTROL_H) {
         do_toggle_control_h(NULL, 1);
@@ -378,11 +379,26 @@
 static void tty_resize(qe__unused__ int sig)
 {
     QEditScreen *s = tty_screen;
-    TTYState *ts = s->priv_data;
+
+    tty_term_invalidate(s);
+
+    //fprintf(stderr, "tty_resize: width=%d, height=%d\n", s->width, 
s->height);
+
+    url_redisplay();
+}
+
+static void tty_term_invalidate(QEditScreen *s)
+{
+    TTYState *ts;
     struct winsize ws;
     int i, count, size;
     TTYChar tc;
 
+    if (s == NULL)
+        return;
+
+    ts = s->priv_data;
+
     s->width = 80;
     s->height = 24;
     if (ioctl(fileno(s->STDIN), TIOCGWINSZ, &ws) == 0) {
@@ -419,11 +435,6 @@
     s->clip_y2 = s->height;
 }
 
-static void tty_term_invalidate(QEditScreen *s)
-{
-    tty_resize(0);
-}
-
 static void tty_term_cursor_at(QEditScreen *s, int x1, int y1,
                                qe__unused__ int w, qe__unused__ int h)
 {

Index: unix.c
===================================================================
RCS file: /sources/qemacs/qemacs/unix.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- unix.c      16 Sep 2015 22:18:25 -0000      1.10
+++ unix.c      17 Apr 2017 23:01:21 -0000      1.11
@@ -2,6 +2,7 @@
  * Unix main loop for QEmacs
  *
  * Copyright (c) 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2000-2017 Charlie Gordon.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -62,6 +63,7 @@
 static int url_fdmax;
 static URLHandler url_handlers[256];
 static int url_exit_request;
+static int url_display_request;
 static LIST_HEAD(pid_handlers);
 static LIST_HEAD(bottom_halves);
 static QETimer *first_timer;
@@ -240,7 +242,7 @@
     url_exit_request = 0;
 }
 
-#define MAX_DELAY 500
+#define MAX_DELAY 500  /* milliseconds */
 
 /* block until one event */
 static void url_block(void)
@@ -313,11 +315,20 @@
 void url_main_loop(void (*init)(void *opaque), void *opaque)
 {
     url_block_reset();
-    init(opaque);
+    (*init)(opaque);
     for (;;) {
         if (url_exit_request)
             break;
         url_block();
+        if (url_display_request) {
+            QEmacsState *qs = &qe_state;
+
+            //qs->complete_refresh = 1;
+            do_refresh(NULL);
+            edit_display(qs);
+            dpy_flush(qs->screen);
+            url_display_request = 0;
+        }
     }
 }
 
@@ -326,3 +337,9 @@
 {
     url_exit_request = 1;
 }
+
+/* asynchronous redisplay signal received */
+void url_redisplay(void)
+{
+    url_display_request = 1;
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]