1*38a227beSBruce Evans /*-
2*38a227beSBruce Evans * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3*38a227beSBruce Evans * All rights reserved.
4*38a227beSBruce Evans *
5*38a227beSBruce Evans * Redistribution and use in source and binary forms, with or without
6*38a227beSBruce Evans * modification, are permitted provided that the following conditions
7*38a227beSBruce Evans * are met:
8*38a227beSBruce Evans * 1. Redistributions of source code must retain the above copyright
9*38a227beSBruce Evans * notice, this list of conditions and the following disclaimer as
10*38a227beSBruce Evans * the first lines of this file unmodified.
11*38a227beSBruce Evans * 2. Redistributions in binary form must reproduce the above copyright
12*38a227beSBruce Evans * notice, this list of conditions and the following disclaimer in the
13*38a227beSBruce Evans * documentation and/or other materials provided with the distribution.
14*38a227beSBruce Evans *
15*38a227beSBruce Evans * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16*38a227beSBruce Evans * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*38a227beSBruce Evans * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*38a227beSBruce Evans * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19*38a227beSBruce Evans * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*38a227beSBruce Evans * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*38a227beSBruce Evans * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*38a227beSBruce Evans * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*38a227beSBruce Evans * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*38a227beSBruce Evans * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*38a227beSBruce Evans */
26*38a227beSBruce Evans
27*38a227beSBruce Evans #ifndef _DEV_SYSCONS_SCTERMVAR_H_
28*38a227beSBruce Evans #define _DEV_SYSCONS_SCTERMVAR_H_
29*38a227beSBruce Evans
30*38a227beSBruce Evans /*
31*38a227beSBruce Evans * building blocks for terminal emulator modules.
32*38a227beSBruce Evans */
33*38a227beSBruce Evans
34*38a227beSBruce Evans static __inline void sc_term_ins_line(scr_stat *scp, int y, int n, int ch,
35*38a227beSBruce Evans int attr, int tail);
36*38a227beSBruce Evans static __inline void sc_term_del_line(scr_stat *scp, int y, int n, int ch,
37*38a227beSBruce Evans int attr, int tail);
38*38a227beSBruce Evans static __inline void sc_term_ins_char(scr_stat *scp, int n, int ch,
39*38a227beSBruce Evans int attr);
40*38a227beSBruce Evans static __inline void sc_term_del_char(scr_stat *scp, int n, int ch,
41*38a227beSBruce Evans int attr);
42*38a227beSBruce Evans static __inline void sc_term_col(scr_stat *scp, int n);
43*38a227beSBruce Evans static __inline void sc_term_row(scr_stat *scp, int n);
44*38a227beSBruce Evans static __inline void sc_term_up(scr_stat *scp, int n, int head);
45*38a227beSBruce Evans static __inline void sc_term_down(scr_stat *scp, int n, int tail);
46*38a227beSBruce Evans static __inline void sc_term_left(scr_stat *scp, int n);
47*38a227beSBruce Evans static __inline void sc_term_right(scr_stat *scp, int n);
48*38a227beSBruce Evans static __inline void sc_term_up_scroll(scr_stat *scp, int n, int ch,
49*38a227beSBruce Evans int attr, int head, int tail);
50*38a227beSBruce Evans static __inline void sc_term_down_scroll(scr_stat *scp, int n, int ch,
51*38a227beSBruce Evans int attr, int head, int tail);
52*38a227beSBruce Evans static __inline void sc_term_clr_eos(scr_stat *scp, int n, int ch, int attr);
53*38a227beSBruce Evans static __inline void sc_term_clr_eol(scr_stat *scp, int n, int ch, int attr);
54*38a227beSBruce Evans static __inline void sc_term_tab(scr_stat *scp, int n);
55*38a227beSBruce Evans static __inline void sc_term_backtab(scr_stat *scp, int n);
56*38a227beSBruce Evans static __inline void sc_term_respond(scr_stat *scp, u_char *s);
57*38a227beSBruce Evans static __inline void sc_term_gen_print(scr_stat *scp, u_char **buf, int *len,
58*38a227beSBruce Evans int attr);
59*38a227beSBruce Evans static __inline void sc_term_gen_scroll(scr_stat *scp, int ch, int attr);
60*38a227beSBruce Evans
61*38a227beSBruce Evans static __inline void
sc_term_ins_line(scr_stat * scp,int y,int n,int ch,int attr,int tail)62*38a227beSBruce Evans sc_term_ins_line(scr_stat *scp, int y, int n, int ch, int attr, int tail)
63*38a227beSBruce Evans {
64*38a227beSBruce Evans if (tail <= 0)
65*38a227beSBruce Evans tail = scp->ysize;
66*38a227beSBruce Evans if (n < 1)
67*38a227beSBruce Evans n = 1;
68*38a227beSBruce Evans if (n > tail - y)
69*38a227beSBruce Evans n = tail - y;
70*38a227beSBruce Evans sc_vtb_ins(&scp->vtb, y*scp->xsize, n*scp->xsize, ch, attr);
71*38a227beSBruce Evans mark_for_update(scp, y*scp->xsize);
72*38a227beSBruce Evans mark_for_update(scp, scp->xsize*tail - 1);
73*38a227beSBruce Evans }
74*38a227beSBruce Evans
75*38a227beSBruce Evans static __inline void
sc_term_del_line(scr_stat * scp,int y,int n,int ch,int attr,int tail)76*38a227beSBruce Evans sc_term_del_line(scr_stat *scp, int y, int n, int ch, int attr, int tail)
77*38a227beSBruce Evans {
78*38a227beSBruce Evans if (tail <= 0)
79*38a227beSBruce Evans tail = scp->ysize;
80*38a227beSBruce Evans if (n < 1)
81*38a227beSBruce Evans n = 1;
82*38a227beSBruce Evans if (n > tail - y)
83*38a227beSBruce Evans n = tail - y;
84*38a227beSBruce Evans sc_vtb_delete(&scp->vtb, y*scp->xsize, n*scp->xsize, ch, attr);
85*38a227beSBruce Evans mark_for_update(scp, y*scp->xsize);
86*38a227beSBruce Evans mark_for_update(scp, scp->xsize*tail - 1);
87*38a227beSBruce Evans }
88*38a227beSBruce Evans
89*38a227beSBruce Evans static __inline void
sc_term_ins_char(scr_stat * scp,int n,int ch,int attr)90*38a227beSBruce Evans sc_term_ins_char(scr_stat *scp, int n, int ch, int attr)
91*38a227beSBruce Evans {
92*38a227beSBruce Evans int count;
93*38a227beSBruce Evans
94*38a227beSBruce Evans if (n < 1)
95*38a227beSBruce Evans n = 1;
96*38a227beSBruce Evans if (n > scp->xsize - scp->xpos)
97*38a227beSBruce Evans n = scp->xsize - scp->xpos;
98*38a227beSBruce Evans count = scp->xsize - (scp->xpos + n);
99*38a227beSBruce Evans sc_vtb_move(&scp->vtb, scp->cursor_pos, scp->cursor_pos + n, count);
100*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, scp->cursor_pos, n, ch, attr);
101*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
102*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos + n + count - 1);
103*38a227beSBruce Evans }
104*38a227beSBruce Evans
105*38a227beSBruce Evans static __inline void
sc_term_del_char(scr_stat * scp,int n,int ch,int attr)106*38a227beSBruce Evans sc_term_del_char(scr_stat *scp, int n, int ch, int attr)
107*38a227beSBruce Evans {
108*38a227beSBruce Evans int count;
109*38a227beSBruce Evans
110*38a227beSBruce Evans if (n < 1)
111*38a227beSBruce Evans n = 1;
112*38a227beSBruce Evans if (n > scp->xsize - scp->xpos)
113*38a227beSBruce Evans n = scp->xsize - scp->xpos;
114*38a227beSBruce Evans count = scp->xsize - (scp->xpos + n);
115*38a227beSBruce Evans sc_vtb_move(&scp->vtb, scp->cursor_pos + n, scp->cursor_pos, count);
116*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, scp->cursor_pos + count, n, ch, attr);
117*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
118*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos + n + count - 1);
119*38a227beSBruce Evans }
120*38a227beSBruce Evans
121*38a227beSBruce Evans static __inline void
sc_term_col(scr_stat * scp,int n)122*38a227beSBruce Evans sc_term_col(scr_stat *scp, int n)
123*38a227beSBruce Evans {
124*38a227beSBruce Evans if (n < 1)
125*38a227beSBruce Evans n = 1;
126*38a227beSBruce Evans sc_move_cursor(scp, n - 1, scp->ypos);
127*38a227beSBruce Evans }
128*38a227beSBruce Evans
129*38a227beSBruce Evans static __inline void
sc_term_row(scr_stat * scp,int n)130*38a227beSBruce Evans sc_term_row(scr_stat *scp, int n)
131*38a227beSBruce Evans {
132*38a227beSBruce Evans if (n < 1)
133*38a227beSBruce Evans n = 1;
134*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos, n - 1);
135*38a227beSBruce Evans }
136*38a227beSBruce Evans
137*38a227beSBruce Evans static __inline void
sc_term_up(scr_stat * scp,int n,int head)138*38a227beSBruce Evans sc_term_up(scr_stat *scp, int n, int head)
139*38a227beSBruce Evans {
140*38a227beSBruce Evans if (n < 1)
141*38a227beSBruce Evans n = 1;
142*38a227beSBruce Evans n = imin(n, scp->ypos - head);
143*38a227beSBruce Evans if (n <= 0)
144*38a227beSBruce Evans return;
145*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos, scp->ypos - n);
146*38a227beSBruce Evans }
147*38a227beSBruce Evans
148*38a227beSBruce Evans static __inline void
sc_term_down(scr_stat * scp,int n,int tail)149*38a227beSBruce Evans sc_term_down(scr_stat *scp, int n, int tail)
150*38a227beSBruce Evans {
151*38a227beSBruce Evans if (tail <= 0)
152*38a227beSBruce Evans tail = scp->ysize;
153*38a227beSBruce Evans if (n < 1)
154*38a227beSBruce Evans n = 1;
155*38a227beSBruce Evans n = imin(n, tail - scp->ypos - 1);
156*38a227beSBruce Evans if (n <= 0)
157*38a227beSBruce Evans return;
158*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos, scp->ypos + n);
159*38a227beSBruce Evans }
160*38a227beSBruce Evans
161*38a227beSBruce Evans static __inline void
sc_term_left(scr_stat * scp,int n)162*38a227beSBruce Evans sc_term_left(scr_stat *scp, int n)
163*38a227beSBruce Evans {
164*38a227beSBruce Evans if (n < 1)
165*38a227beSBruce Evans n = 1;
166*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos - n, scp->ypos);
167*38a227beSBruce Evans }
168*38a227beSBruce Evans
169*38a227beSBruce Evans static __inline void
sc_term_right(scr_stat * scp,int n)170*38a227beSBruce Evans sc_term_right(scr_stat *scp, int n)
171*38a227beSBruce Evans {
172*38a227beSBruce Evans if (n < 1)
173*38a227beSBruce Evans n = 1;
174*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos + n, scp->ypos);
175*38a227beSBruce Evans }
176*38a227beSBruce Evans
177*38a227beSBruce Evans static __inline void
sc_term_up_scroll(scr_stat * scp,int n,int ch,int attr,int head,int tail)178*38a227beSBruce Evans sc_term_up_scroll(scr_stat *scp, int n, int ch, int attr, int head, int tail)
179*38a227beSBruce Evans {
180*38a227beSBruce Evans if (tail <= 0)
181*38a227beSBruce Evans tail = scp->ysize;
182*38a227beSBruce Evans if (n < 1)
183*38a227beSBruce Evans n = 1;
184*38a227beSBruce Evans if (n <= scp->ypos - head) {
185*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos, scp->ypos - n);
186*38a227beSBruce Evans } else {
187*38a227beSBruce Evans sc_term_ins_line(scp, head, n - (scp->ypos - head),
188*38a227beSBruce Evans ch, attr, tail);
189*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos, head);
190*38a227beSBruce Evans }
191*38a227beSBruce Evans }
192*38a227beSBruce Evans
193*38a227beSBruce Evans static __inline void
sc_term_down_scroll(scr_stat * scp,int n,int ch,int attr,int head,int tail)194*38a227beSBruce Evans sc_term_down_scroll(scr_stat *scp, int n, int ch, int attr, int head, int tail)
195*38a227beSBruce Evans {
196*38a227beSBruce Evans if (tail <= 0)
197*38a227beSBruce Evans tail = scp->ysize;
198*38a227beSBruce Evans if (n < 1)
199*38a227beSBruce Evans n = 1;
200*38a227beSBruce Evans if (n < tail - scp->ypos) {
201*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos, scp->ypos + n);
202*38a227beSBruce Evans } else {
203*38a227beSBruce Evans sc_term_del_line(scp, head, n - (tail - scp->ypos) + 1,
204*38a227beSBruce Evans ch, attr, tail);
205*38a227beSBruce Evans sc_move_cursor(scp, scp->xpos, tail - 1);
206*38a227beSBruce Evans }
207*38a227beSBruce Evans }
208*38a227beSBruce Evans
209*38a227beSBruce Evans static __inline void
sc_term_clr_eos(scr_stat * scp,int n,int ch,int attr)210*38a227beSBruce Evans sc_term_clr_eos(scr_stat *scp, int n, int ch, int attr)
211*38a227beSBruce Evans {
212*38a227beSBruce Evans switch (n) {
213*38a227beSBruce Evans case 0: /* clear form cursor to end of display */
214*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, scp->cursor_pos,
215*38a227beSBruce Evans scp->xsize*scp->ysize - scp->cursor_pos,
216*38a227beSBruce Evans ch, attr);
217*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
218*38a227beSBruce Evans mark_for_update(scp, scp->xsize*scp->ysize - 1);
219*38a227beSBruce Evans sc_remove_cutmarking(scp);
220*38a227beSBruce Evans break;
221*38a227beSBruce Evans case 1: /* clear from beginning of display to cursor */
222*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, 0, scp->cursor_pos + 1, ch, attr);
223*38a227beSBruce Evans mark_for_update(scp, 0);
224*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
225*38a227beSBruce Evans sc_remove_cutmarking(scp);
226*38a227beSBruce Evans break;
227*38a227beSBruce Evans case 2: /* clear entire display */
228*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, 0, scp->xsize*scp->ysize, ch, attr);
229*38a227beSBruce Evans mark_for_update(scp, 0);
230*38a227beSBruce Evans mark_for_update(scp, scp->xsize*scp->ysize - 1);
231*38a227beSBruce Evans sc_remove_cutmarking(scp);
232*38a227beSBruce Evans break;
233*38a227beSBruce Evans }
234*38a227beSBruce Evans }
235*38a227beSBruce Evans
236*38a227beSBruce Evans static __inline void
sc_term_clr_eol(scr_stat * scp,int n,int ch,int attr)237*38a227beSBruce Evans sc_term_clr_eol(scr_stat *scp, int n, int ch, int attr)
238*38a227beSBruce Evans {
239*38a227beSBruce Evans switch (n) {
240*38a227beSBruce Evans case 0: /* clear form cursor to end of line */
241*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, scp->cursor_pos,
242*38a227beSBruce Evans scp->xsize - scp->xpos, ch, attr);
243*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
244*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos +
245*38a227beSBruce Evans scp->xsize - 1 - scp->xpos);
246*38a227beSBruce Evans break;
247*38a227beSBruce Evans case 1: /* clear from beginning of line to cursor */
248*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, scp->cursor_pos - scp->xpos,
249*38a227beSBruce Evans scp->xpos + 1, ch, attr);
250*38a227beSBruce Evans mark_for_update(scp, scp->ypos*scp->xsize);
251*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
252*38a227beSBruce Evans break;
253*38a227beSBruce Evans case 2: /* clear entire line */
254*38a227beSBruce Evans sc_vtb_erase(&scp->vtb, scp->cursor_pos - scp->xpos,
255*38a227beSBruce Evans scp->xsize, ch, attr);
256*38a227beSBruce Evans mark_for_update(scp, scp->ypos*scp->xsize);
257*38a227beSBruce Evans mark_for_update(scp, (scp->ypos + 1)*scp->xsize - 1);
258*38a227beSBruce Evans break;
259*38a227beSBruce Evans }
260*38a227beSBruce Evans }
261*38a227beSBruce Evans
262*38a227beSBruce Evans static __inline void
sc_term_tab(scr_stat * scp,int n)263*38a227beSBruce Evans sc_term_tab(scr_stat *scp, int n)
264*38a227beSBruce Evans {
265*38a227beSBruce Evans int i;
266*38a227beSBruce Evans
267*38a227beSBruce Evans if (n < 1)
268*38a227beSBruce Evans n = 1;
269*38a227beSBruce Evans i = (scp->xpos & ~7) + 8*n;
270*38a227beSBruce Evans if (i >= scp->xsize) {
271*38a227beSBruce Evans if (scp->ypos >= scp->ysize - 1) {
272*38a227beSBruce Evans scp->xpos = 0;
273*38a227beSBruce Evans scp->ypos++;
274*38a227beSBruce Evans scp->cursor_pos = scp->ypos*scp->xsize;
275*38a227beSBruce Evans } else
276*38a227beSBruce Evans sc_move_cursor(scp, 0, scp->ypos + 1);
277*38a227beSBruce Evans } else
278*38a227beSBruce Evans sc_move_cursor(scp, i, scp->ypos);
279*38a227beSBruce Evans }
280*38a227beSBruce Evans
281*38a227beSBruce Evans static __inline void
sc_term_backtab(scr_stat * scp,int n)282*38a227beSBruce Evans sc_term_backtab(scr_stat *scp, int n)
283*38a227beSBruce Evans {
284*38a227beSBruce Evans int i;
285*38a227beSBruce Evans
286*38a227beSBruce Evans if (n < 1)
287*38a227beSBruce Evans n = 1;
288*38a227beSBruce Evans if ((i = scp->xpos & ~7) == scp->xpos)
289*38a227beSBruce Evans i -= 8*n;
290*38a227beSBruce Evans else
291*38a227beSBruce Evans i -= 8*(n - 1);
292*38a227beSBruce Evans if (i < 0)
293*38a227beSBruce Evans i = 0;
294*38a227beSBruce Evans sc_move_cursor(scp, i, scp->ypos);
295*38a227beSBruce Evans }
296*38a227beSBruce Evans
297*38a227beSBruce Evans static __inline void
sc_term_respond(scr_stat * scp,u_char * s)298*38a227beSBruce Evans sc_term_respond(scr_stat *scp, u_char *s)
299*38a227beSBruce Evans {
300*38a227beSBruce Evans sc_paste(scp, s, strlen(s)); /* XXX: not correct, don't use rmap */
301*38a227beSBruce Evans }
302*38a227beSBruce Evans
303*38a227beSBruce Evans static __inline void
sc_term_gen_print(scr_stat * scp,u_char ** buf,int * len,int attr)304*38a227beSBruce Evans sc_term_gen_print(scr_stat *scp, u_char **buf, int *len, int attr)
305*38a227beSBruce Evans {
306*38a227beSBruce Evans vm_offset_t p;
307*38a227beSBruce Evans u_char *ptr;
308*38a227beSBruce Evans u_char *map;
309*38a227beSBruce Evans int cnt;
310*38a227beSBruce Evans int l;
311*38a227beSBruce Evans int i;
312*38a227beSBruce Evans
313*38a227beSBruce Evans ptr = *buf;
314*38a227beSBruce Evans l = *len;
315*38a227beSBruce Evans
316*38a227beSBruce Evans if (PRINTABLE(*ptr)) {
317*38a227beSBruce Evans p = sc_vtb_pointer(&scp->vtb, scp->cursor_pos);
318*38a227beSBruce Evans map = scp->sc->scr_map;
319*38a227beSBruce Evans
320*38a227beSBruce Evans cnt = imin(l, scp->xsize - scp->xpos);
321*38a227beSBruce Evans i = cnt;
322*38a227beSBruce Evans do {
323*38a227beSBruce Evans p = sc_vtb_putchar(&scp->vtb, p, map[*ptr], attr);
324*38a227beSBruce Evans ++ptr;
325*38a227beSBruce Evans --i;
326*38a227beSBruce Evans } while ((i > 0) && PRINTABLE(*ptr));
327*38a227beSBruce Evans
328*38a227beSBruce Evans l -= cnt - i;
329*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
330*38a227beSBruce Evans scp->cursor_pos += cnt - i;
331*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos - 1);
332*38a227beSBruce Evans scp->xpos += cnt - i;
333*38a227beSBruce Evans
334*38a227beSBruce Evans if (scp->xpos >= scp->xsize) {
335*38a227beSBruce Evans scp->xpos = 0;
336*38a227beSBruce Evans scp->ypos++;
337*38a227beSBruce Evans /* we may have to scroll the screen */
338*38a227beSBruce Evans }
339*38a227beSBruce Evans } else {
340*38a227beSBruce Evans switch(*ptr) {
341*38a227beSBruce Evans case 0x07:
342*38a227beSBruce Evans sc_bell(scp, scp->bell_pitch, scp->bell_duration);
343*38a227beSBruce Evans break;
344*38a227beSBruce Evans
345*38a227beSBruce Evans case 0x08: /* non-destructive backspace */
346*38a227beSBruce Evans /* XXX */
347*38a227beSBruce Evans if (scp->cursor_pos > 0) {
348*38a227beSBruce Evans #if 0
349*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
350*38a227beSBruce Evans scp->cursor_pos--;
351*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
352*38a227beSBruce Evans #else
353*38a227beSBruce Evans scp->cursor_pos--;
354*38a227beSBruce Evans #endif
355*38a227beSBruce Evans if (scp->xpos > 0) {
356*38a227beSBruce Evans scp->xpos--;
357*38a227beSBruce Evans } else {
358*38a227beSBruce Evans scp->xpos += scp->xsize - 1;
359*38a227beSBruce Evans scp->ypos--;
360*38a227beSBruce Evans }
361*38a227beSBruce Evans }
362*38a227beSBruce Evans break;
363*38a227beSBruce Evans
364*38a227beSBruce Evans case 0x09: /* non-destructive tab */
365*38a227beSBruce Evans sc_term_tab(scp, 1);
366*38a227beSBruce Evans /* we may have to scroll the screen */
367*38a227beSBruce Evans #if 0
368*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
369*38a227beSBruce Evans scp->cursor_pos += (8 - scp->xpos % 8u);
370*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
371*38a227beSBruce Evans scp->xpos += (8 - scp->xpos % 8u);
372*38a227beSBruce Evans if (scp->xpos >= scp->xsize) {
373*38a227beSBruce Evans scp->xpos = 0;
374*38a227beSBruce Evans scp->ypos++;
375*38a227beSBruce Evans }
376*38a227beSBruce Evans #endif
377*38a227beSBruce Evans break;
378*38a227beSBruce Evans
379*38a227beSBruce Evans case 0x0a: /* newline, same pos */
380*38a227beSBruce Evans #if 0
381*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
382*38a227beSBruce Evans scp->cursor_pos += scp->xsize;
383*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
384*38a227beSBruce Evans #else
385*38a227beSBruce Evans scp->cursor_pos += scp->xsize;
386*38a227beSBruce Evans /* we may have to scroll the screen */
387*38a227beSBruce Evans #endif
388*38a227beSBruce Evans scp->ypos++;
389*38a227beSBruce Evans break;
390*38a227beSBruce Evans
391*38a227beSBruce Evans case 0x0c: /* form feed, clears screen */
392*38a227beSBruce Evans sc_clear_screen(scp);
393*38a227beSBruce Evans break;
394*38a227beSBruce Evans
395*38a227beSBruce Evans case 0x0d: /* return, return to pos 0 */
396*38a227beSBruce Evans #if 0
397*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
398*38a227beSBruce Evans scp->cursor_pos -= scp->xpos;
399*38a227beSBruce Evans mark_for_update(scp, scp->cursor_pos);
400*38a227beSBruce Evans #else
401*38a227beSBruce Evans scp->cursor_pos -= scp->xpos;
402*38a227beSBruce Evans #endif
403*38a227beSBruce Evans scp->xpos = 0;
404*38a227beSBruce Evans break;
405*38a227beSBruce Evans }
406*38a227beSBruce Evans ptr++; l--;
407*38a227beSBruce Evans }
408*38a227beSBruce Evans
409*38a227beSBruce Evans *buf = ptr;
410*38a227beSBruce Evans *len = l;
411*38a227beSBruce Evans }
412*38a227beSBruce Evans
413*38a227beSBruce Evans static __inline void
sc_term_gen_scroll(scr_stat * scp,int ch,int attr)414*38a227beSBruce Evans sc_term_gen_scroll(scr_stat *scp, int ch, int attr)
415*38a227beSBruce Evans {
416*38a227beSBruce Evans /* do we have to scroll ?? */
417*38a227beSBruce Evans if (scp->cursor_pos >= scp->ysize*scp->xsize) {
418*38a227beSBruce Evans sc_remove_cutmarking(scp); /* XXX */
419*38a227beSBruce Evans #ifndef SC_NO_HISTORY
420*38a227beSBruce Evans if (scp->history != NULL)
421*38a227beSBruce Evans sc_hist_save_one_line(scp, 0); /* XXX */
422*38a227beSBruce Evans #endif
423*38a227beSBruce Evans sc_vtb_delete(&scp->vtb, 0, scp->xsize, ch, attr);
424*38a227beSBruce Evans scp->cursor_pos -= scp->xsize;
425*38a227beSBruce Evans scp->ypos--;
426*38a227beSBruce Evans mark_all(scp);
427*38a227beSBruce Evans }
428*38a227beSBruce Evans }
429*38a227beSBruce Evans
430*38a227beSBruce Evans #endif /* _DEV_SYSCONS_SCTERMVAR_H_ */
431