bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] How to set the screen width in APL interpreter


From: Alexey Veretennikov
Subject: Re: [Bug-apl] How to set the screen width in APL interpreter
Date: Sun, 25 Dec 2016 10:24:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin)

Hi,

Yes I understand your reasoning.
I've searched about ⎕PW behavior in IBM Reference
manual as well as tested its behavior with Dyalog APL.
As it states in IBM Reference Manual ⎕PW is a session-wide variable,
therefore I guess should not be attached to the workspace. In Dyalog
APL according to my experiments it is the case.
So I've taken the liberty to implement the command-line argument to set
the value of ⎕PW system variable as "--PW value", so the users who know
their terminal width (like I am since I'm running the terminal with
command line geometry option) could set the appropriate width.
I've also modified Archive to not to load this variable from workspaces
and use default one (or provided in command line argument) to comply
with IBM APL reference manual.

Kindly see the patch attached.
Index: src/Archive.cc
===================================================================
--- src/Archive.cc      (revision 827)
+++ src/Archive.cc      (working copy)
@@ -1752,9 +1752,11 @@
    Log(LOG_archive)   CERR << "    read_Symbol() name=" << name_ucs << endl;
 
    // ⎕NLT was removed, but could lurk around in old workspaces.
+   // ⎕PW is a session-wide variable
    //
    if (name_ucs == UCS_string(UTF8_string("⎕NLT")) ||
-       name_ucs == UCS_string(UTF8_string("⎕PT")))
+       name_ucs == UCS_string(UTF8_string("⎕PT")) ||
+       name_ucs == UCS_string(UTF8_string("⎕PW")))
       {
         Log(LOG_archive)   CERR << "        skipped at " << LOC << endl;
         skip_to_tag("/Symbol");
Index: src/SystemVariable.cc
===================================================================
--- src/SystemVariable.cc       (revision 827)
+++ src/SystemVariable.cc       (working copy)
@@ -567,7 +567,7 @@
 Quad_PW::Quad_PW()
    : SystemVariable(ID::Quad_PW)
 {
-   Symbol::assign(IntScalar(DEFAULT_Quad_PW, LOC), false, LOC);
+   Symbol::assign(IntScalar(uprefs.initial_pw, LOC), false, LOC);
 }
 //-----------------------------------------------------------------------------
 void
Index: src/UserPreferences.cc
===================================================================
--- src/UserPreferences.cc      (revision 827)
+++ src/UserPreferences.cc      (working copy)
@@ -116,6 +116,8 @@
 "    --TS                 append to (rather than override) summary.log\n"
 "    -v, --version        show version information and exit\n"
 "    -w milli             wait milli milliseconds at startup\n"
+"    --PW value           initial value of the width of terminal window\n"
+"                         (80 by default)\n"
 "    --                   end of options for %s\n", prog);
    CERR << cc << endl;
 }
@@ -594,7 +596,25 @@
               wait_ms = atoi(val);
               continue;
             }
+         if (!strcmp(opt, "--PW"))
+            {
+              ++a;
+              if (!val)
+                {
+                  CERR << "the --PW option should be followed by numeric 
argument" << endl;
+                  exit(a);
+                }
+              initial_pw = atoi(val);
+              if (initial_pw < MIN_Quad_PW || initial_pw > MAX_Quad_PW)
+                {
+                  CERR << "the --PW option should be within the limits [" << 
MIN_Quad_PW;
+                  CERR << ".." << MAX_Quad_PW << "]" << endl;
+                  exit(a);
+                }
+              continue;
+            }
 
+
          CERR << "unknown option '" << opt << "'" << endl;
          usage(expanded_argv[0]);
          exit(a);
Index: src/UserPreferences.hh
===================================================================
--- src/UserPreferences.hh      (revision 827)
+++ src/UserPreferences.hh      (working copy)
@@ -55,7 +55,8 @@
      line_history_len(500),
      nabla_to_history(1),   // if function was modified
      control_Ds_to_exit(0),
-     raw_cin(false)
+     raw_cin(false),
+     initial_pw(DEFAULT_Quad_PW)
    {}
 
    /// read a \b preference file and update parameters set there
@@ -181,6 +182,8 @@
    /// send no ESC sequences on stderr
    bool raw_cin;
 
+   /// initial value of the Quad_PW system variable
+   int initial_pw;
 protected:
    /// open a user-supplied config file (in $HOME or gnu-apl.d)
    FILE * open_user_file(const char * fname, char * opened_filename,

Juergen Sauermann <address@hidden> writes:

> Hi Alexey,
>
> I do not think this is a good idea.
>
> I believe many people will be surprised if ⎕PW is different from 80.
> And GNU APL does not necessarily run in a terminal. In my experience,
> the terminal width is a fairly unreliable parameter on many platforms, and
> adjusting ⎕PW automatically is asking for trouble.
>
> So for the sake of compatibility and the principle of least surprises, I 
> leave ⎕PW at 80.
>
> Please not also that negative ⎕FIO arguments are not protable and not
> available on all platforms (that's why they are not documented).
>
> Most people do not put things in ⎕LX directly but have some larger APL 
> function that
> is called from ⎕LX. So an extra line in that function which sets ⎕PW is 
> probably the
> better solution.
>
> /// Jürgen
>
> On 12/24/2016 10:13 AM, Alexey Veretennikov wrote:
>
>  Thanks! Both versions works for me on OSX, however on my small linux box tput
> is not available while ⎕FIO¯8 works fine.
>
> Jurgen, maybe it could be added as a default configuration for GNU APL
> interpreter? From usability point it rather confusing to set this
> variable manually (right now I did it in ⎕LX in CONTINUE workspace)
>
> Christian Robert <address@hidden> writes:
>
>        ⎕fio ¯8
> 200
>
> undocumented ⎕fio ¯8 give you the window width,
>
> Xtian.
>
>
> On 2016-12-23 19:43, Kacper Gutowski wrote:
>
>  On Sat, Dec 24, 2016 at 12:14:41AM +0100, Alexey Veretennikov wrote:
>
>  I'm running GNU APL in the X terminal with geometry 48x15 (it is
>  a small
> screen). How could I set this width(48) to the GNU APL interpreter so it
> will behave correctly on deletion of characters in long lines etc?
>
>
> Setting print width affects line editing as well.  It should wrap
> correctly if you set ⎕PW to the width of your terminal.
>
>       ⎕PW←⍎↑⍎')HOST tput cols'
>
> Sometimes I wish GNU APL did this automatically on WINCH.
>
> -k
>
>
>
>

-- 
Br,
/Alexey

reply via email to

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