include var.h and lcmd.c only in some of the parser?.c
[unix-history] / usr / src / usr.bin / window / lcmd1.c
index b1b6dcd..8e46826 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)lcmd1.c     3.8 83/11/23";
+static char *sccsid = "@(#)lcmd1.c     3.13 84/01/12";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -8,10 +8,10 @@ static        char *sccsid = "@(#)lcmd1.c     3.8 83/11/23";
 #include "lcmd.h"
 
 struct lcmd_arg arg_window[] = {
 #include "lcmd.h"
 
 struct lcmd_arg arg_window[] = {
-       { "row",        1,      ARG_NUM },
-       { "column",     1,      ARG_NUM },
-       { "nrows",      2,      ARG_NUM },
-       { "ncols",      2,      ARG_NUM },
+       { "row",        1,      ARG_ANY },
+       { "column",     1,      ARG_ANY },
+       { "nrows",      2,      ARG_ANY },
+       { "ncols",      2,      ARG_ANY },
        { "nlines",     2,      ARG_NUM },
        { "label",      1,      ARG_STR },
        { 0,            0,      0 }
        { "nlines",     2,      ARG_NUM },
        { "label",      1,      ARG_STR },
        { 0,            0,      0 }
@@ -26,16 +26,16 @@ register struct value *v;
 
        if ((id = findid()) < 0)
                return;
 
        if ((id = findid()) < 0)
                return;
-       row = a->arg_vtype == V_ERR ? 1 : a->arg_num;
-       col = (++a)->arg_vtype == V_ERR ? 0 : a->arg_num;
-       nrow = (++a)->arg_vtype == V_ERR ? wwnrow - row : a->arg_num;
-       ncol = (++a)->arg_vtype == V_ERR ? wwncol - col : a->arg_num;
+       row = a->arg_vtype != V_NUM ? 1 : a->arg_num;
+       col = (++a)->arg_vtype != V_NUM ? 0 : a->arg_num;
+       nrow = (++a)->arg_vtype != V_NUM ? wwnrow - row : a->arg_num;
+       ncol = (++a)->arg_vtype != V_NUM ? wwncol - col : a->arg_num;
        nline = (++a)->arg_vtype == V_ERR ? nbufline : a->arg_num;
        label =  (++a)->arg_vtype == V_ERR ? 0 : a->arg_str;
        if (openwin(id, row, col, nrow, ncol, nline, label) == 0)
                return;
        v->v_type = V_NUM;
        nline = (++a)->arg_vtype == V_ERR ? nbufline : a->arg_num;
        label =  (++a)->arg_vtype == V_ERR ? 0 : a->arg_str;
        if (openwin(id, row, col, nrow, ncol, nline, label) == 0)
                return;
        v->v_type = V_NUM;
-       v->v_num = id;
+       v->v_num = id + 1;
 }
 
 struct lcmd_arg arg_buffer[] = {
 }
 
 struct lcmd_arg arg_buffer[] = {
@@ -63,7 +63,7 @@ struct value *v;
        struct ww *w;
 
        v->v_type = V_NUM;
        struct ww *w;
 
        v->v_type = V_NUM;
-       v->v_num = selwin ? selwin->ww_id : -1;
+       v->v_num = selwin ? selwin->ww_id + 1 : -1;
        if (arg_select[0].arg_vtype == V_ERR)
                return;
        if ((w = vtowin(&arg_select[0].arg_val)) == 0)
        if (arg_select[0].arg_vtype == V_ERR)
                return;
        if ((w = vtowin(&arg_select[0].arg_val)) == 0)
@@ -71,6 +71,19 @@ struct value *v;
        setselwin(w);
 }
 
        setselwin(w);
 }
 
+struct lcmd_arg arg_debug[] = {
+       { "flag",       1,      ARG_ANY },
+       { 0,            0,      0 }
+};
+
+l_debug(v)
+struct value *v;
+{
+       v->v_type = V_NUM;
+       v->v_num = debug;
+       debug = vtobool(&arg_debug[0].arg_val, 1, debug);
+}
+
 struct lcmd_arg arg_escape[] = {
        { "escapec",    1,      ARG_NUM },
        { 0,            0,      0 }
 struct lcmd_arg arg_escape[] = {
        { "escapec",    1,      ARG_NUM },
        { 0,            0,      0 }
@@ -173,23 +186,55 @@ l_close(v)
 struct value *v;
 {
        register struct lcmd_arg *a = arg_close;
 struct value *v;
 {
        register struct lcmd_arg *a = arg_close;
-       register i;
        struct ww *w;
 
        struct ww *w;
 
-       if (a->arg_vtype == V_ERR) {
+       if (a->arg_vtype == V_ERR)
                c_close((struct ww *)0);
                c_close((struct ww *)0);
+       else if ((w = vtowin(&a->arg_val)) != 0)
+               c_close(w);
+}
+
+struct lcmd_arg arg_cursormodes[] = {
+       { "modes",      1,      ARG_NUM },
+       { 0,            0,      0 }
+};
+
+l_cursormodes(v)
+register struct value *v;
+{
+       register struct lcmd_arg *a = arg_cursormodes;
+
+       v->v_type = V_NUM;
+       v->v_num = wwcursormodes;
+       if (a->arg_vtype != V_ERR)
+               wwsetcursormodes(a->arg_num);
+}
+
+struct lcmd_arg arg_unset[] = {
+       { "variable",   1,      ARG_ANY },
+       { 0,            0,      0 }
+};
+
+l_unset(v)
+register struct value *v;
+{
+       register struct lcmd_arg *a = arg_unset;
+
+       v->v_type = V_NUM;
+       switch (a->arg_vtype) {
+       case V_ERR:
+               v->v_num = -1;
                return;
                return;
+       case V_NUM:
+               if ((a->arg_str = str_cpy(a->arg_num)) == 0) {
+                       error("Out of memory.");
+                       v->v_num = -1;
+                       return;
+               }
+               a->arg_vtype = V_STR;
+               break;
        }
        }
-       if ((w = vtowin(&a->arg_val)) == 0)
-               return;
-       closewin(w);
-       if (selwin == 0) {
-               for (i = 0; i < NWINDOW && window[i] != 0; i++)
-                       ;
-               if (i < NWINDOW)
-                       setselwin(window[i]);
-       }
-       reframe();
+       v->v_num = var_unset(a->arg_str);
 }
 
 struct ww *
 }
 
 struct ww *