Changeset: 7d85d410d4af for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7d85d410d4af
Modified Files:
        clients/ChangeLog.Sep2022
        clients/mapiclient/mclient.1
        clients/mapiclient/mclient.c
Branch: Sep2022
Log Message:

Implemented adaptive window height in internal pager.


diffs (77 lines):

diff --git a/clients/ChangeLog.Sep2022 b/clients/ChangeLog.Sep2022
--- a/clients/ChangeLog.Sep2022
+++ b/clients/ChangeLog.Sep2022
@@ -1,3 +1,8 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Mon Apr 17 2023 Sjoerd Mullender <[email protected]>
+- If the number of rows in mclient is set to 0 (using either --rows=0
+  option or \r0 on the mclient command line), the internal pager is used
+  and it then uses the height of the terminal window.
+
diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -320,6 +320,8 @@ query.  Remote content is retrieved by
 \fB\-\-rows=\fP\fInr\fP (\fB\-r\fP \fInr\fP)
 If specified, query results will be paged by an internal pager at the
 specified number of lines.
+If set to \fB0\fP (zero), use the height of the terminal.
+The default is \fB\-1\fP which means no pager is used.
 .TP
 \fB\-\-width=\fP\fInr\fP (\fB\-w\fP \fInr\fP)
 Specify the width of the screen.
@@ -422,7 +424,11 @@ If
 .I rows
 is
 .BR \-1 ,
-stop using the internal pager.
+stop using the internal pager, if
+.I rows
+is
+.BR 0 ,
+use the height of the terminal.
 .SS
 SQL Commands
 .TP
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -126,8 +126,9 @@ static char *pager = 0;             /* use external
 #ifdef HAVE_SIGACTION
 #include <signal.h>            /* to block SIGPIPE */
 #endif
-static int rowsperpage = 0;    /* for SQL pagination */
+static int rowsperpage = -1;   /* for SQL pagination */
 static int pagewidth = 0;      /* -1: take whatever is necessary, >0: limit */
+static int pageheight = 0;     /* -1: take whatever is necessary, >0: limit */
 static bool pagewidthset = false; /* whether the user set the width explicitly 
*/
 static int croppedfields = 0;  /* whatever got cropped/truncated */
 static bool firstcrop = true;  /* first time we see cropping/truncation */
@@ -1407,6 +1408,8 @@ SQLrenderer(MapiHdl hdl)
        bool skiprest = false;
        int64_t rows;                           /* total number of rows */
 
+       if (ps == 0)
+               ps = pageheight;
        croppedfields = 0;
        fields = mapi_get_field_count(hdl);
        rows = mapi_get_row_count(hdl);
@@ -1738,12 +1741,13 @@ setWidth(void)
 #ifdef TIOCGWINSZ
                struct winsize ws;
 
-               if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) == 0 && ws.ws_col > 
0)
+               if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) == 0 && ws.ws_col > 
0) {
                        pagewidth = ws.ws_col;
-               else
+                       pageheight = ws.ws_row;
+               } else
 #endif
                {
-                       pagewidth = -1;
+                       pagewidth = pageheight = -1;
                }
        }
 }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to