[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] For discussion: patch to get some terminal info and do
From: |
Ulf Dambacher |
Subject: |
[open-cobol-list] For discussion: patch to get some terminal info and do scrolling |
Date: |
Thu, 08 Jan 2009 21:55:43 +0100 |
User-agent: |
Thunderbird 2.0.0.18 (X11/20081105) |
Hi
Just for discussion: enclosed you find a patch to OC 1.1 wich implements
following syntax extensions:
1) ACCEPT field FROM TERMINAL SCREEN_COLUMNS
2) ACCEPT field FROM TERMINAL SCREEN_LINES
3) ACCEPT field ... [ SCROLL [UP / DOWN ] [ BY n [_LINES ]] ...
4) DISPLAY field ... [ SCROLL [UP / DOWN ] [ BY n [_LINES ]] ...
to 1+2:
Somehow one has to figure out how many lines/cols the screen has.
We don't have fixed size terminals anymore .-(
Acucobol has this syntax:
ACCEPT structure FROM TERMINAL-INFO
and a copy library for working storage to put some information about
screen lines, color usage, highlight etc.
Can we copy this 1:1 without copyright probelems?
Shall we have our own syntax?
to 3+4:
Currently we can't do scrolling in OC. I found there are different ways
in different compilers.
Acucobol scrolls if one moves to the last line, last column and displays
something. Also they have a syntax like this to do scrolling explicitly.
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-list] For discussion: patch to get some terminal info and do scrolling,
Ulf Dambacher <=