Commit | Line | Data |
---|---|---|
bd002416 | 1 | #ifndef lint |
a4c3bba5 | 2 | static char *sccsid = "@(#)lcmd1.c 3.4 83/08/22"; |
bd002416 EW |
3 | #endif |
4 | ||
5 | #include "defs.h" | |
6 | ||
7 | struct ww *openwin(); | |
8 | struct ww *idtowin(); | |
9 | ||
10 | l_window() | |
11 | { | |
12 | register char **pp = argv; | |
13 | register struct ww *w; | |
14 | int col, row, ncol, nrow, id; | |
15 | ||
16 | if ((id = findid()) < 0) { | |
17 | error("Too many windows."); | |
18 | return; | |
19 | } | |
20 | if (**++pp == '*') | |
21 | row = 1; | |
22 | else | |
23 | row = atoi(*pp); | |
24 | if (**++pp == '*') | |
25 | col = 0; | |
26 | else | |
27 | col = atoi(*pp); | |
28 | if (**++pp == '*') | |
29 | nrow = wwnrow - row; | |
30 | else | |
31 | nrow = atoi(*pp); | |
32 | if (**++pp == '*') | |
33 | ncol = wwncol - col; | |
34 | else | |
35 | ncol = atoi(*pp); | |
36 | w = openwin(id, nrow, ncol, row, col); | |
37 | if (w == 0) | |
38 | error("Can't open window: row %d col %d, %d rows %d cols.", | |
39 | row, col, nrow, ncol); | |
40 | } | |
41 | ||
42 | l_select() | |
43 | { | |
44 | struct ww *w; | |
45 | ||
46 | if ((w = idtowin(*argv + 1)) == 0) | |
47 | return; | |
48 | setselwin(w); | |
49 | } | |
50 | ||
51 | l_escape() | |
52 | { | |
53 | setescape(argv[1]); | |
54 | } | |
55 | ||
56 | l_label() | |
57 | { | |
58 | struct ww *w; | |
59 | ||
60 | if ((w = idtowin(argv[1])) == 0) | |
61 | return; | |
62 | if (setlabel(w, argv[2]) < 0) | |
63 | error("Out of memory."); | |
64 | reframe(); | |
65 | } | |
66 | ||
67 | l_terse() | |
68 | { | |
69 | char oldterse = terse; | |
70 | ||
71 | if (argc < 2) | |
72 | terse = 1; | |
73 | else if (strcmp(argv[1], "off") == 0) | |
74 | terse = 0; | |
75 | else | |
76 | terse = 1; | |
77 | if (terse && !oldterse) | |
78 | wwdelete(cmdwin); | |
79 | else if (!terse && oldterse) | |
80 | wwadd(cmdwin, &wwhead); | |
81 | reframe(); | |
82 | } | |
83 | ||
84 | l_source() | |
85 | { | |
86 | if (insource) { | |
87 | error("Recursive source."); | |
88 | return; | |
89 | } | |
90 | if (dosource(argv[1]) < 0) | |
91 | error("Can't open %s.", argv[1]); | |
92 | } | |
93 | ||
94 | l_write() | |
95 | { | |
96 | struct ww *w; | |
97 | ||
98 | if ((w = idtowin(argv[1])) == 0) | |
99 | return; | |
100 | (void) write(w->ww_pty, argv[2], strlen(argv[2])); | |
101 | } | |
102 | ||
8aee01cc EW |
103 | l_close() |
104 | { | |
105 | register i; | |
106 | register struct ww *w; | |
107 | char didit = 0; | |
108 | ||
a4c3bba5 EW |
109 | if (argc < 2) { |
110 | c_close((struct ww *)0); | |
111 | return; | |
112 | } | |
8aee01cc EW |
113 | for (i = 1; i < argc; i++) { |
114 | if ((w = idtowin(argv[i])) == 0) | |
115 | continue; | |
116 | closewin(w); | |
117 | didit++; | |
118 | } | |
119 | if (selwin == 0) { | |
120 | for (i = 0; i < NWINDOW && window[i] != 0; i++) | |
121 | ; | |
122 | if (i < NWINDOW) | |
123 | setselwin(window[i]); | |
124 | } | |
125 | if (didit) | |
126 | reframe(); | |
127 | } | |
128 | ||
bd002416 EW |
129 | struct ww * |
130 | idtowin(idstr) | |
131 | char *idstr; | |
132 | { | |
133 | register id; | |
134 | struct ww *w; | |
135 | ||
136 | id = atoi(idstr) - 1; | |
137 | if (id < 0 || id >= NWINDOW || (w = window[id]) == 0) { | |
138 | error("%d: No such window.", id + 1); | |
139 | return 0; | |
140 | } | |
141 | return w; | |
142 | } |