gnucobol-users
[Top][All Lists]
Advanced

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

Re: [open-cobol-list] For discussion: patch to get some terminal info an


From: Ulf Dambacher
Subject: Re: [open-cobol-list] For discussion: patch to get some terminal info and do scrolling
Date: Fri, 09 Jan 2009 15:11:22 +0100
User-agent: Thunderbird 2.0.0.18 (X11/20081105)

Hi
I'm sorry, but the patch missed one file. This one here will compile cleanly.
bye
Ulf
diff -ur open-cobol-1.1/cobc/parser.y open-cobol-1.1-ud1/cobc/parser.y
--- open-cobol-1.1/cobc/parser.y        2008-08-08 13:02:51.000000000 +0200
+++ open-cobol-1.1-ud1/cobc/parser.y    2009-01-06 10:15:42.000000000 +0100
@@ -97,6 +97,9 @@
 
 static cb_tree                 fgc;
 static cb_tree                 bgc;
+static cb_tree                 scroll;
+static int                     scroll_direction;
+
 static int                     next_label_id = 0;
 static int                     current_linage = 0;
 static int                     eval_level = 0;
@@ -420,7 +423,10 @@
 %token RUN
 %token SAME
 %token SCREEN
+%token SCREEN_LINES            "SCREEN-LINES"
+%token SCREEN_COLUMNS          "SCREEN-COLUMNS"
 %token SCREEN_CONTROL          "SCREEN-CONTROL"
+%token SCROLL
 %token SD
 %token SEARCH
 %token SECTION
@@ -457,6 +463,7 @@
 %token SYNCHRONIZED
 %token TALLYING
 %token TAPE
+%token TERMINAL
 %token TEST
 %token THAN
 %token THEN
@@ -2761,15 +2768,17 @@
        dispattrs = 0;
        fgc = NULL;
        bgc = NULL;
+       scroll = NULL;
+       scroll_direction=1;
   }
   accept_body
   end_accept
 ;
 
 accept_body:
-  identifier opt_at_line_column opt_accp_attr on_accp_exception
+  identifier opt_at_line_column opt_scroll opt_accp_attr on_accp_exception
   {
-       cb_emit_accept ($1, $2, fgc, bgc, dispattrs);
+    cb_emit_accept ($1, $2, fgc, bgc, dispattrs,scroll,scroll_direction);
   }
 | identifier FROM ESCAPE KEY
   {
@@ -2781,6 +2790,8 @@
 | identifier FROM DAY YYYYDDD                          { 
cb_emit_accept_day_yyyyddd ($1); }
 | identifier FROM DAY_OF_WEEK                          { 
cb_emit_accept_day_of_week ($1); }
 | identifier FROM TIME                                 { cb_emit_accept_time 
($1); }
+| identifier FROM TERMINAL SCREEN_LINES                        { 
cb_emit_accept_screen_lines ($1); }
+| identifier FROM TERMINAL SCREEN_COLUMNS              { 
cb_emit_accept_screen_columns ($1); }
 | identifier FROM COMMAND_LINE                         { 
cb_emit_accept_command_line ($1); }
 | identifier FROM ENVIRONMENT_VALUE on_accp_exception  { 
cb_emit_accept_environment ($1); }
 | identifier FROM ENVIRONMENT simple_value on_accp_exception
@@ -2810,6 +2821,20 @@
   COLUMN _number id_or_lit     { $$ = $3; }
 ;
 
+opt_scroll:
+| SCROLL scroll_direction scroll_lines
+;
+
+scroll_direction:
+/* empty */ { scroll_direction=1; }
+| UP { scroll_direction=1;  }
+| DOWN { scroll_direction=-1 ; }
+;
+scroll_lines:
+/* empty */ { scroll= cb_int1; }
+| BY id_or_lit _line_or_lines { scroll =$2; }
+;
+
 opt_accp_attr:
 | WITH accp_attrs
 ;
@@ -3190,11 +3215,13 @@
        dispattrs = 0;
        fgc = NULL;
        bgc = NULL;
+       scroll = NULL;
+       scroll_direction=1;
   }
-  x_list opt_at_line_column display_upon with_clause on_disp_exception
+  x_list opt_at_line_column opt_scroll display_upon with_clause 
on_disp_exception
   end_display
   {
-       cb_emit_display ($3, $5, $6, $4, fgc, bgc, dispattrs);
+    cb_emit_display ($3, $5, $6, $4, fgc, bgc, dispattrs,scroll, 
scroll_direction);
   }
 ;
 
Nur in open-cobol-1.1-ud1/cobc: parser.y~.
diff -ur open-cobol-1.1/cobc/reserved.c open-cobol-1.1-ud1/cobc/reserved.c
--- open-cobol-1.1/cobc/reserved.c      2008-07-28 16:22:53.000000000 +0200
+++ open-cobol-1.1-ud1/cobc/reserved.c  2009-01-06 10:22:57.000000000 +0100
@@ -490,6 +490,9 @@
   {"RUN",              RUN},                   /* 2002 */
   {"SAME",             SAME},                  /* 2002 */
   {"SCREEN",           SCREEN},                /* 2002 */
+  {"SCREEN-COLUMNS",   SCREEN_COLUMNS},        /* extension */
+  {"SCREEN-LINES",     SCREEN_LINES},          /* extension */
+  {"SCROLL",           SCROLL},                /* extension */
   {"SD",               SD},                    /* 2002 */
   {"SEARCH",           SEARCH},                /* 2002 */
   {"SECONDS",          -1},                    /* 2002 (C/S) */
@@ -544,7 +547,7 @@
   {"TABLE",            -1},                    /* 2002 */
   {"TALLYING",         TALLYING},              /* 2002 */
   {"TAPE",             TAPE},                  /* 85 */
-  {"TERMINAL",         -1},                    /* 2002 */
+  {"TERMINAL",         TERMINAL},              /* 2002 */
   {"TERMINATE",                -1},                    /* 2002 */
   {"TEST",             TEST},                  /* 2002 */
   {"TEXT",             -1},                    /* 2002 */
diff -ur open-cobol-1.1/cobc/tree.h open-cobol-1.1-ud1/cobc/tree.h
--- open-cobol-1.1/cobc/tree.h  2008-07-28 16:22:53.000000000 +0200
+++ open-cobol-1.1-ud1/cobc/tree.h      2009-01-06 10:13:42.000000000 +0100
@@ -1219,13 +1219,15 @@
 extern void cb_emit_corresponding (cb_tree (*func) (cb_tree f1, cb_tree f2, 
cb_tree f3), cb_tree x1, cb_tree x2, cb_tree opt);
 extern void cb_emit_move_corresponding (cb_tree x1, cb_tree x2);
 
-extern void cb_emit_accept (cb_tree var, cb_tree pos, cb_tree fgc, cb_tree 
bgc, int dispattrs);
+extern void cb_emit_accept (cb_tree var, cb_tree pos, cb_tree fgc, cb_tree 
bgc, int dispattrs, cb_tree scroll, int scroll_direction);
 extern void cb_emit_accept_date (cb_tree var);
 extern void cb_emit_accept_date_yyyymmdd (cb_tree var);
 extern void cb_emit_accept_day (cb_tree var);
 extern void cb_emit_accept_day_yyyyddd (cb_tree var);
 extern void cb_emit_accept_day_of_week (cb_tree var);
 extern void cb_emit_accept_time (cb_tree var);
+extern void cb_emit_accept_screen_lines (cb_tree var);
+extern void cb_emit_accept_screen_columns (cb_tree var);
 extern void cb_emit_accept_command_line (cb_tree var);
 extern void cb_emit_get_environment (cb_tree envvar, cb_tree envval);
 extern void cb_emit_accept_environment (cb_tree var);
@@ -1250,7 +1252,7 @@
 extern void cb_emit_delete (cb_tree file);
 
 extern void cb_emit_display (cb_tree values, cb_tree upon, cb_tree no_adv, 
cb_tree pos,
-                               cb_tree fgc, cb_tree bgc, int dispattrs);
+                            cb_tree fgc, cb_tree bgc, int dispattrs,cb_tree 
scroll, int scroll_direction);
 extern cb_tree cb_build_display_upon (cb_tree x);
 extern cb_tree cb_build_display_upon_direct (cb_tree x);
 extern void cb_emit_env_name (cb_tree value);
Nur in open-cobol-1.1-ud1/cobc: tree.h~.
diff -ur open-cobol-1.1/libcob/screenio.c open-cobol-1.1-ud1/libcob/screenio.c
--- open-cobol-1.1/libcob/screenio.c    2008-07-28 16:22:55.000000000 +0200
+++ open-cobol-1.1-ud1/libcob/screenio.c        2009-01-06 10:14:36.000000000 
+0100
@@ -909,6 +909,55 @@
        refresh ();
 }
 
+void cob_scroll(cob_field *nroflines, int direction) 
+{
+       int lines;
+       
+       if (!screen_initialized) {
+               cob_screen_init ();
+       }
+
+       lines=cob_get_int(nroflines);
+       if (lines<0) return;
+       scrollok(stdscr, 1);
+       scrl(direction*lines);
+       scrollok(stdscr, 0);
+       refresh();
+}
+
+void cob_accept_screen_lines(cob_field *f){
+       int             n;
+       cob_field_attr  attr;
+       cob_field       temp;
+
+       if (!screen_initialized) {
+               cob_screen_init ();
+       }
+       n=LINES;
+       temp.size = 4;
+       temp.data = (unsigned char *)&n;
+       temp.attr = &attr;
+       COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 9, 0, 0, NULL);
+       cob_move (&temp, f);
+}
+
+void cob_accept_screen_columns(cob_field *f)
+{
+       int             n;
+       cob_field_attr  attr;
+       cob_field       temp;
+
+       if (!screen_initialized) {
+               cob_screen_init ();
+       }
+       n=COLS;
+       temp.size = 4;
+       temp.data = (unsigned char *)&n;
+       temp.attr = &attr;
+       COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 9, 0, 0, NULL);
+       cob_move (&temp, f);
+}
+
 #else
 
 void
@@ -941,4 +990,15 @@
 {
 }
 
+void cob_scroll(cob_field nroflines, int direction) 
+{ 
+}
+
+void cob_accept_screen_lines(cob_field *f)
+{ 
+}
+void cob_accept_screen_columns(cob_field *f)
+{ 
+}
+
 #endif
diff -ur open-cobol-1.1/libcob/screenio.h open-cobol-1.1-ud1/libcob/screenio.h
--- open-cobol-1.1/libcob/screenio.h    2008-07-28 16:22:55.000000000 +0200
+++ open-cobol-1.1-ud1/libcob/screenio.h        2009-01-06 10:14:09.000000000 
+0100
@@ -85,4 +85,8 @@
 extern void cob_field_accept (cob_field *f, cob_field *line, cob_field *column,
                                cob_field *fgc, cob_field *bgc, int attr);
 
+extern void cob_scroll(cob_field *nroflines, int direction);
+extern void cob_accept_screen_lines(cob_field *f);
+extern void cob_accept_screen_columns(cob_field *f);
+
 #endif /* COB_SCREENIO_H */
--- open-cobol-1.1/cobc/typeck.c        2008-07-30 13:16:19.000000000 +0200
+++ open-cobol-1.1-ud1/cobc/typeck.c    2009-01-06 10:13:23.000000000 +0100
@@ -2747,7 +2747,7 @@
  */
 
 void
-cb_emit_accept (cb_tree var, cb_tree pos, cb_tree fgc, cb_tree bgc, int 
dispattrs)
+cb_emit_accept (cb_tree var, cb_tree pos, cb_tree fgc, cb_tree bgc, int 
dispattrs, cb_tree scroll, int scroll_direction)
 {
        cb_tree line;
        cb_tree column;
@@ -2764,6 +2764,9 @@
        if (cb_validate_one (bgc)) {
                return;
        }
+       if (cb_validate_one (scroll)) {
+               return;
+       }
        if (current_program->flag_screen) {
                if ((CB_FIELD_P (var) || CB_REFERENCE_P (var))
                    && CB_FIELD (cb_ref (var))->storage == CB_STORAGE_SCREEN) {
@@ -2779,6 +2782,9 @@
                        gen_screen_ptr = 0;
                        output_screen_to (CB_FIELD (cb_ref (var)), 0);
                } else {
+                       if (scroll) {
+                               cb_emit( cb_build_funcall_2 
("cob_scroll",scroll, cb_int(scroll_direction)));
+                       }
                        if (pos || fgc || bgc) {
                                if (!pos) {
                                        cb_emit (cb_build_funcall_6 
("cob_field_accept", var, NULL, NULL, fgc, bgc, cb_int(dispattrs)));
@@ -2863,6 +2869,24 @@
 }
 
 void
+cb_emit_accept_screen_lines (cb_tree var)
+{
+       if (cb_validate_one (var)) {
+               return;
+       }
+       cb_emit (cb_build_funcall_1 ("cob_accept_screen_lines", var));
+}
+
+void
+cb_emit_accept_screen_columns (cb_tree var)
+{
+       if (cb_validate_one (var)) {
+               return;
+       }
+       cb_emit (cb_build_funcall_1 ("cob_accept_screen_columns", var));
+}
+
+void
 cb_emit_accept_command_line (cb_tree var)
 {
        if (cb_validate_one (var)) {
@@ -3193,7 +3217,7 @@
 
 void
 cb_emit_display (cb_tree values, cb_tree upon, cb_tree no_adv, cb_tree pos,
-                cb_tree fgc, cb_tree bgc, int dispattrs)
+                cb_tree fgc, cb_tree bgc, int dispattrs,cb_tree scroll, int 
scroll_direction)
 {
        cb_tree l;
        cb_tree x;
@@ -3215,6 +3239,9 @@
        if (cb_validate_one (bgc)) {
                return;
        }
+       if (cb_validate_one (scroll)) {
+               return;
+       }
        for (l = values; l; l = CB_CHAIN (l)) {
                x = CB_VALUE (l);
                if (x == cb_error_node) {
@@ -3307,6 +3334,9 @@
                }
                gen_screen_ptr = 0;
        } else if (pos || fgc || bgc || dispattrs) {
+               if (scroll) {
+                       cb_emit( cb_build_funcall_2 ("cob_scroll",scroll, 
cb_int(scroll_direction)));
+               }
                if (!pos) {
                        cb_emit (cb_build_funcall_6 ("cob_field_display", 
CB_VALUE (values),
                                NULL, NULL, fgc, bgc, cb_int(dispattrs)));

reply via email to

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