* Copyright (c) 1992 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
* %sccs.include.redist.c%
* from: $Hdr: vt100esc.c,v 4.300 91/06/09 06:14:59 root Rel41 $ SONY
* @(#)vt100esc.c 7.2 (Berkeley) %G%
* vt100 escape sequence handler
#include "../include/fix_machine_type.h"
#include "../../h/param.h"
#include "../../h/systm.h"
#include "../../iop/framebuf.h"
#include "../iop/framebuf.h"
#include "../bm/bitmapif.h"
#include "../fb/fbdefs.h"
#include "../../iop/kbreg.h"
#include "../../iop/keyboard.h"
#include "../iop/kbreg.h"
#include "../iop/keyboard.h"
#define kbd_ioctl(chan, cmd, argp) { \
(*kb_ioctl)(chan, cmd, argp); \
* escape sequece functions
int esc_application_kpad();
struct esc_sequence esc_seq_table
[] = {
{'[', "ABCDfgHhJKLlMmnPr", esc_csi
},
{'7', "", esc_store_csr
},
{'8', "", esc_restore_csr
},
{'E', "", esc_next_line
},
{'M', "", esc_rev_index
},
{'=', "", esc_application_kpad
},
{'>', "", esc_numeric_kpad
},
{'#', "34568", esc_line_size
},
{'(', "0ABJH", esc_char_setr
},
{')', "0AB", esc_char_setl
},
{'$', "B@", esc_kanji_set
},
{'~', "fcpsomdbDiGCBTtE", esc_parm_set
},
{'P', "pPZiI", esc_pf_define
},
struct key_pad key_pad
[] = {
{ '.', 'n' }, /* period */
{ '-', 'm' }, /* minus */
{ ',', 'l' }, /* comma */
{ '\n', 'M' }, /* enter */
{ 'A', 'A' }, /* cursor up */
{ 'B', 'B' }, /* cursor down */
{ 'C', 'C' }, /* cursor right */
{ 'D', 'D' }, /* cursor left */
static char esc_buf
[ESC_BUF_SIZ
];
static char *esc_bp
= esc_buf
;
extern char c_pos_mess
[];
unsigned int first_jcode
;
addch(sp
, c
| (first_jcode
<< 8));
* This routine is the command analiser using second character.
* If a command has found then switch to particular escape handling
* routine, and directly called by mother routine.
* The arguments are passed through the routine.
register struct esc_sequence
*estp
;
for (estp
= esc_seq_table
; estp
->command
; estp
++) {
if (estp
->command
== c
) {
if (*estp
->terminators
== '\0') {
sp
->s_current_stat
&= ~ESCAPE
;
sp
->s_esc_handler
= estp
->esc_func
;
sp
->s_current_stat
&= ~ESCAPE
;
* Undo the ESCAPE flag, escape buffer
* and the esc_handler routine
* This routine has to be called when escape sequence has started.
register int *ip
= (int *) esc_buf
;
register int *sup
= (int *) (esc_buf
+ ESC_BUF_SIZ
);
sp
->s_current_stat
&= ~ESCAPE
;
sp
->s_esc_handler
= esc_top_level
;
* This routine in_str(c, string) returns
* if string contains c then TRUE (1) else FALSE (0)
* Control sequence introducer (CSI)
* Which begins `^[[' and terminates one of `ABCDfgHhJKLlMmPr'
if (in_str(c
, sp
->s_estp
->terminators
)) {
esc_csi_ansi(sp
, esc_bp
, c
);
sp
->s_current_stat
&= ~ESCAPE
;
/* buffering arguments */
if (bufc
< ESC_BUF_SIZ
) {
if (c
>= '0' && c
<= '9') {
*esc_bp
= *esc_bp
*10 + (c
- '0');
sp
->s_esc_handler
= esc_csi_dec
;
sp
->s_current_stat
&= ~ESCAPE
;
* Ansi standard csi handler
esc_csi_ansi(sp
, esc_bp
, terminator
)
register char *cp
= esc_buf
;
register struct cursor
*spc
= &sp
->s_csr
;
if (spc
->csr_y
< sp
->s_region
.top_margin
) {
spc
->csr_y
= max(spc
->csr_y
- max(*cp
, 1)
spc
->csr_y
= max(spc
->csr_y
- max(*cp
, 1)
,sp
->s_region
.top_margin
);
spc
->csr_p
.y
= (spc
->csr_y
- 1) * char_h
+ y_ofst
;
sp
->s_current_stat
&= ~WRAP
;
if (spc
->csr_y
> sp
->s_region
.btm_margin
) {
spc
->csr_y
= min(spc
->csr_y
+ max(*cp
, 1)
spc
->csr_y
= min(spc
->csr_y
+ max(*cp
, 1)
,sp
->s_region
.btm_margin
);
spc
->csr_p
.y
= (spc
->csr_y
- 1) * char_h
+ y_ofst
;
sp
->s_current_stat
&= ~WRAP
;
spc
->csr_x
= min(spc
->csr_x
+ max(*cp
, 1), rit_m
);
spc
->csr_p
.x
= (spc
->csr_x
- 1) * char_w
+ x_ofst
;
sp
->s_current_stat
&= ~WRAP
;
spc
->csr_x
= max(spc
->csr_x
- max(*cp
, 1), LFT_M
);
spc
->csr_p
.x
= (spc
->csr_x
- 1) * char_w
+ x_ofst
;
sp
->s_current_stat
&= ~WRAP
;
sp
->s_tab_pos
[spc
->csr_x
] = 0;
for (i
= 0; i
<= rit_m
; i
++)
case 'H': /* CUP same as HVP */
csr_pos(sp
, cp
[1], cp
[0]);
sp
->s_current_stat
&= ~WRAP
;
sp
->s_current_stat
&= ~WRAP
;
sp
->s_current_stat
&= ~WRAP
;
sp
->s_current_stat
&= ~WRAP
;
cp
[2] = max(cp
[0] == 0 ? TOP_M
: cp
[0], TOP_M
);
cp
[3] = min(cp
[1] == 0 ? btm_m
: cp
[1], btm_m
);
sp
->s_region
.top_margin
= cp
[2];
sp
->s_region
.btm_margin
= cp
[3];
if (sp
->s_term_mode
& DECOM
) {
spc
->csr_y
= sp
->s_region
.top_margin
;
spc
->csr_p
.y
= (spc
->csr_y
- 1) * char_h
+ y_ofst
;
spc
->csr_attributes
&= NORMALM
;
if (sp
->s_term_mode
& DECSCNM
) {
spc
->csr_attributes
|= BOLD
;
case 4: /* under score */
spc
->csr_attributes
|= USCORE
;
spc
->csr_attributes
|= BLINK
;
spc
->csr_attributes
|= REVERSE
;
if (sp
->s_term_mode
& DECSCNM
) {
spc
->csr_attributes
&= ~BOLD
;
case 24: /* no under score */
spc
->csr_attributes
&= ~USCORE
;
case 25: /* no blinking */
spc
->csr_attributes
&= ~BLINK
;
case 27: /* re-reverse */
spc
->csr_attributes
&= ~REVERSE
;
if (sp
->s_term_mode
& DECSCNM
) {
while (cp
<= esc_bp
) { /* DSR(status request) */
case 6: /* inquiry cursor position */
key_str
.key_string
= c_pos_mess
;
key_str
.key_length
= spr(c_pos_mess
,
"\033[%d;%dR", (sp
->s_term_mode
& DECOM
) ?
spc
->csr_y
- sp
->s_region
.top_margin
+ 1:
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
case 2: /* Keyboard Action */
case 4: /* Insert Replace */
case 12: /* Local echo disable */
case 20: /* Linefeed newline */
case 2: /* Keyboard Action */
case 4: /* Insert Replace */
case 12: /* Local echo disable */
case 20: /* Linefeed newline */
sp
->s_current_stat
&= ~ESCAPE
;
* csr_pos(sp, x, y) moves the cursor to (x, y).
if (sp
->s_term_mode
& DECOM
) {
sp
->s_csr
.csr_y
= min(sp
->s_region
.top_margin
+
max(y
, 1) - 1, sp
->s_region
.btm_margin
);
sp
->s_csr
.csr_y
= min(TOP_M
+ max(y
, 1) - 1, btm_m
);
sp
->s_csr
.csr_x
= max(min(x
, rit_m
), LFT_M
);
sp
->s_csr
.csr_p
.x
= (sp
->s_csr
.csr_x
-1) * char_w
+ x_ofst
;
sp
->s_csr
.csr_p
.y
= (sp
->s_csr
.csr_y
-1) * char_h
+ y_ofst
;
* erase_disp(sp, pn) erases display from the cursor to the end, from
* the beginning to the cursor or completely according to pn = 0, 1 or 2
register struct cursor
*spc
= &sp
->s_csr
;
case 0: /* cursor to end */
clear_lines(min(spc
->csr_y
+ 1, btm_m
),
btm_m
- spc
->csr_y
, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
case 1: /* beginning to cursor */
clear_lines(TOP_M
, spc
->csr_y
- TOP_M
, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
clear_lines(TOP_M
, btm_m
- TOP_M
+ 1,
sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
* erase_line(sp, pn) erases line from the cursor to the end, from the
* beginning to the cursor or completely according to pn = 0, 1 or 2
register struct cursor
*spc
= &sp
->s_csr
;
clear_chars(spc
->csr_x
, spc
->csr_y
,
rit_m
- spc
->csr_x
+ 1, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
clear_chars(LFT_M
, spc
->csr_y
,
spc
->csr_x
- LFT_M
+ 1, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
clear_lines(spc
->csr_y
, 1, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
* insert_line(sp, pn) inserts pn lines in scroll region
register struct cursor
*spc
= &sp
->s_csr
;
register struct region
*spr
= &sp
->s_region
;
if (spc
->csr_y
< spr
->top_margin
|| spc
->csr_y
> spr
->btm_margin
)
if (pn
<= spr
->btm_margin
- spc
->csr_y
) {
move_lines(spc
->csr_y
, spr
->btm_margin
- pn
- spc
->csr_y
+ 1,
min(spc
->csr_y
+ pn
- 1, spr
->btm_margin
) - spc
->csr_y
+ 1,
sp
->s_term_mode
& DECSCNM
, sp
->s_plane
, sp
->s_bgcol
);
* delete_line(sp, pn) deletes pn lines in scroll region
register struct cursor
*spc
= &sp
->s_csr
;
register struct region
*spr
= &sp
->s_region
;
if (spc
->csr_y
< spr
->top_margin
|| spc
->csr_y
> spr
->btm_margin
)
if (pn
<= spr
->btm_margin
- spc
->csr_y
) {
move_lines(aux
, spr
->btm_margin
- aux
+ 1, spc
->csr_y
);
aux
= max(spr
->btm_margin
- pn
+ 1, spc
->csr_y
);
clear_lines(aux
, spr
->btm_margin
- aux
+ 1, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
* delete_char(sp, pn) deletes pn characters right side of the cursor.
register struct cursor
*spc
= &sp
->s_csr
;
if (pn
< rit_m
- spc
->csr_x
+ 1) {
move_chars(spc
->csr_x
+ pn
, spc
->csr_y
,
rit_m
- spc
->csr_x
- pn
+ 1 ,spc
->csr_x
);
aux
= max(rit_m
- pn
+ 1, spc
->csr_x
);
clear_chars(aux
, spc
->csr_y
, rit_m
- aux
+ 1,
sp
->s_term_mode
& DECSCNM
, sp
->s_plane
, sp
->s_bgcol
);
* This escape control sequence begins `^[[?' and ends `h' or `l'
if (in_str(c
, sp
->s_estp
->terminators
)) {
if (esc_buf
[0] != INVALID
) {
for (cp
= esc_buf
; cp
<= esc_bp
; cp
++) {
case 1: /* cursor key application */
sp
->s_term_mode
|= DECCKM
;
change_csr_key_pad(APPLIC
);
case 3: /* 132 column mode */
sp
->s_term_mode
|= DECCOLM
;
case 4: /* jump scroll */
sp
->s_term_mode
|= DECSCLM
;
if ((sp
->s_term_mode
& DECSCNM
) == 0)
sp
->s_term_mode
|= DECSCNM
;
if (sp
->s_csr
.csr_attributes
& REVERSE
)
sp
->s_term_mode
|= DECOM
;
sp
->s_csr
.csr_p
.x
= x_ofst
;
(sp
->s_csr
.csr_y
- 1) * char_h
+
sp
->s_term_mode
|= DECAWM
;
case 8: /* auto repeat */
if ((sp
->s_term_mode
& DECARM
) == 0) {
kbd_ioctl(SCC_KEYBOARD
, KIOCREPT
,
sp
->s_term_mode
|= DECARM
;
case 25: /* cursor active */
sp
->s_term_mode
|= DECCSR_ACTV
;
case 'l': /* reset mode */
for (cp
= esc_buf
; cp
<= esc_bp
; cp
++) {
case 1: /* cursor key application */
sp
->s_term_mode
&= ~DECCKM
;
change_csr_key_pad(NUMERIC
);
case 3: /* 132 column mode */
sp
->s_term_mode
&= ~DECCOLM
;
case 4: /* jump scroll */
sp
->s_term_mode
&= ~DECSCLM
;
if (sp
->s_term_mode
& DECSCNM
)
sp
->s_term_mode
&= ~DECSCNM
;
if (sp
->s_csr
.csr_attributes
& REVERSE
)
sp
->s_term_mode
&= ~DECOM
;
sp
->s_csr
.csr_p
.x
= x_ofst
;
sp
->s_csr
.csr_p
.y
= y_ofst
;
sp
->s_term_mode
&= ~DECAWM
;
case 8: /* auto repeat */
if (sp
->s_term_mode
& DECARM
) {
kbd_ioctl(SCC_KEYBOARD
, KIOCNRPT
,
sp
->s_term_mode
&= ~DECARM
;
case 25: /* cursor non-active */
sp
->s_term_mode
&= ~DECCSR_ACTV
;
cursor_on(&sp
->s_csr
.csr_p
);
sp
->s_current_stat
&= ~ESCAPE
;
} else { /* buffering arguments */
if (c
>= '0' && c
<= '9') {
*esc_bp
= *esc_bp
* 10 + (c
- '0');
sp
->s_current_stat
&= ~ESCAPE
;
* changes cursor key pad to ansi_ctl
change_csr_key_pad(applic
)
register Pfk_string
*pfk
= &pfk_str
;
register Key_string
*kys
= &pfk_str
.pfk_string
;
register struct key_pad
*kpd
;
pad
[1] = (applic
) ? 'O': '[';
for (i
= UP
; i
<= LEFT
; i
++) {
kys
->key_length
= (applic
) ? 3: 3;
pad
[2] = (applic
) ? kpd
->kpd_applic
: kpd
->kpd_numeric
;
pfk
->pfk_shift
= PF_NORMAL
;
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
pfk
->pfk_shift
= PF_SHIFT
;
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
extern struct cursor inner_buf_csr
;
extern int inner_buf_tstat
;
* Store cursor position and attributes.
* The SCREEN structure is stored inner structure.
inner_buf_csr
= sp
->s_csr
;
inner_buf_tstat
= (DECOM
|DECAWM
) & sp
->s_term_mode
;
* Restore cursor position and attributes.
* The SCREEN structure is restored from inner structure.
* Prevail error from unexpected use of this command, inner structure
sp
->s_csr
= inner_buf_csr
;
sp
->s_term_mode
= (sp
->s_term_mode
& ~(DECOM
|DECAWM
)) | inner_buf_tstat
;
cursor_on(&sp
->s_csr
.csr_p
);
* esc_index(sp) moves the cursor down if the cursor is not at
* bottom margin. If the cursor is at the bottom margin then
if (sp
->s_csr
.csr_y
== sp
->s_region
.btm_margin
)
scroll_up(sp
->s_region
.top_margin
,
sp
->s_region
.btm_margin
, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
if (sp
->s_csr
.csr_y
< btm_m
) {
sp
->s_csr
.csr_p
.y
+= char_h
;
sp
->s_current_stat
&= ~WRAP
;
cursor_on(&sp
->s_csr
.csr_p
);
* esc_next_line(sp) moves the cursor down like index but the cursor
* position is the beginning of the next line.
sp
->s_csr
.csr_p
.x
= x_ofst
;
* esc_tab_set(sp) sets tabulation stop at the current cursor point.
sp
->s_tab_pos
[sp
->s_csr
.csr_x
] = 1;
* esc_rev_index(sp) moves the cursor up if the cursor is not at the top
* margin. If the cursor is at the top margin then the screen takes place
if (sp
->s_csr
.csr_y
== sp
->s_region
.top_margin
)
scroll_down(sp
->s_region
.top_margin
,
sp
->s_region
.btm_margin
, sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
if (sp
->s_csr
.csr_y
> TOP_M
) {
sp
->s_csr
.csr_p
.y
-= char_h
;
sp
->s_current_stat
&= ~WRAP
;
cursor_on(&sp
->s_csr
.csr_p
);
* esc_numeric_kpad(sp) changes key pad of cursor to numeric one.
* This sequence is used in vi.
* currently not supported
change_aux_key_pad(NUMERIC
);
sp
->s_current_stat
&= ~ESCAPE
;
* esc_application_kpad(sp) changes key pad of cursor to application one.
* This sequence is also used in vi.
* currently not supported.
change_aux_key_pad(APPLIC
);
sp
->s_current_stat
&= ~ESCAPE
;
* change auxiliary keypad
change_aux_key_pad(applic
)
register Pfk_string
*pfk
= &pfk_str
;
register Key_string
*kys
= &pfk_str
.pfk_string
;
register struct key_pad
*kpd
;
for (i
= N0
; i
<= NENTER
; i
++) {
kys
->key_length
= (applic
) ? 3: 1;
pad
[2] = kpd
->kpd_applic
;
pad
[0] = kpd
->kpd_numeric
;
pfk
->pfk_shift
= PF_NORMAL
;
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
pfk
->pfk_shift
= PF_SHIFT
;
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
pfk
->pfk_shift
= PF_SHIFT
;
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
extern struct csr_buf local_csr_buf
;
* esc_line_size(sp, pn) changes line size.
* c = `3' double side double height(top half)
* c = `4' double side double height(bottom half)
* c = `5' sigle width line
* c = `6' double width line
* currently not supported
local_csr_buf
.csr_number
= 1;
local_csr_buf
.csr_number
= 2;
sp
->s_region
.top_margin
= TOP_M
;
sp
->s_region
.btm_margin
= btm_m
;
sp
->s_csr
.csr_p
.y
= y_ofst
;
for (i
= TOP_M
; i
<= btm_m
; i
++) {
sp
->s_csr
.csr_p
.x
= x_ofst
;
for (j
= LFT_M
; j
<= rit_m
; j
++) {
sp
->s_csr
.csr_p
.x
+= char_w
;
sp
->s_csr
.csr_p
.y
+= char_h
;
sp
->s_csr
.csr_p
.x
= x_ofst
;
sp
->s_csr
.csr_p
.y
= y_ofst
;
cursor_on(&sp
->s_csr
.csr_p
);
sp
->s_current_stat
&= ~ESCAPE
;
* esc_char_setr sets which character set you use in right graphic set.
* currently not supported
#if defined(IPC_MRX) || defined(CPU_SINGLE)
sp
->s_current_stat
&= ~JKANJI
;
sp
->s_current_stat
&= ~JKANJI
;
#else /* IPC_MRX || CPU_SINGLE */
if (c
== 'B' || c
== 'J' || c
== 'H') {
sp
->s_current_stat
&= ~JKANJI
;
#endif /* IPC_MRX || CPU_SINGLE */
sp
->s_current_stat
&= ~ESCAPE
;
* character set to left graphic set
* esc_char_setl sets which character set you use in left graphic set.
* currently not supported
sp
->s_current_stat
&= ~ESCAPE
;
extern unsigned int first_jcode
;
* esc_kanji_set sets kanji
if (tmode
== KM_JIS
&& (c
== 'B' || c
== '@')) {
sp
->s_current_stat
|= JKANJI
;
sp
->s_current_stat
&= ~ESCAPE
;
static short parm_buf
[PARM_BUF_SIZ
];
static short *parm_bp
= parm_buf
;
static int sensitive
= 0;
* terminal parameter set command
* esc_parm_set(sp, c) sets terminal parameters such as font-width,
* font-height, character-width, character-height, character-position,
* underlind-position, screen-width, screen-height, x-offset, y-offset,
* right-mergin, bottom-mergin, dimmer-count, bell-length.
if (in_str(c
, sp
->s_estp
->terminators
)) {
parm_set(sp
, parm_buf
, c
);
sp
->s_current_stat
&= ~ESCAPE
;
/* buffering arguments */
if (bufc
< PARM_BUF_SIZ
) {
if (c
>= '0' && c
<= '9') {
pval
= pval
*10 + (c
- '0');
sp
->s_current_stat
&= ~ESCAPE
;
static char an_buf
[AN_BUF_SIZ
];
parm_set(sp
, parm
, terminator
)
register char *bp
= an_buf
;
if (parm
[0] >= FONT_W_MIN
&& parm
[0] <= consfb
->font_w
&&
if (parm
[1] >= FONT_H_MIN
&& parm
[1] <= consfb
->font_h
&&
parm
[1] <= (char_h
- ch_pos
))
if (parm
[0] >= CHAR_W_MIN
&& parm
[0] > font_w
&&
if (parm
[1] >= CHAR_H_MIN
&& parm
[1] >= (font_h
+ ch_pos
) &&
parm
[1] > ul_pos
&& parm
[1] <= CHAR_H_MAX
)
if (parm
[0] >= UL_POS_MIN
&& parm
[0] <= UL_POS_MAX
&&
if (parm
[1] >= CH_POS_MIN
&& parm
[1] <= CH_POS_MAX
&&
parm
[1] < (char_h
- font_h
)) {
if (parm
[0] > SCR_W_MIN
&& parm
[0] <= consfb
->scr_w
)
scr_w
= (parm
[0] < char_w
) ? char_w
: parm
[0];
if (parm
[1] > SCR_H_MIN
&& parm
[1] <= consfb
->scr_h
)
scr_h
= (parm
[1] < char_h
) ? char_h
: parm
[1];
if (parm
[0] >= X_OFST_MIN
&& parm
[0] <= X_OFST_MAX
)
x_ofst
= (parm
[0] > scr_w
- char_w
) ?
(scr_w
- char_w
): parm
[0];
if (parm
[1] >= Y_OFST_MIN
&& parm
[1] <= Y_OFST_MAX
)
y_ofst
= (parm
[1] > scr_h
- char_h
) ?
(scr_h
- char_h
): parm
[1];
if (parm
[0] >= RIT_M_MIN
) {
if (parm
[0] > RIT_M_MAX
/* consfb->rit_m */) {
rit_m
= (parm
[0] > (scr_w
- x_ofst
)/char_w
) ?
(scr_w
- x_ofst
)/char_w
: parm
[0];
if (parm
[1] >= BTM_M_MIN
) {
if (parm
[1] > BTM_M_MAX
/* consfb->btm_m */) {
btm_m
= (parm
[1] > (scr_h
- y_ofst
)/char_h
) ?
(scr_h
- y_ofst
)/char_h
: parm
[1];
if (parm
[0] >= DIM_CNT_MIN
&& parm
[0] <= DIM_CNT_MAX
)
dim_cnt
= a_dim_on
= parm
[0];
if (parm
[0] >= BELL_LEN_MIN
&& parm
[0] <= BELL_LEN_MAX
)
csr_pos(sp
, LFT_M
, TOP_M
);
key_str
.key_string
= c_pos_mess
;
key_str
.key_length
= spr(c_pos_mess
, "f=(%d,%d), ",
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
key_str
.key_length
= spr(c_pos_mess
, "c=(%d,%d), ",
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
csr_pos(sp
, LFT_M
, (TOP_M
- 1));
key_str
.key_string
= c_pos_mess
;
key_str
.key_length
= spr(c_pos_mess
, "p=(%d,%d), ",
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
key_str
.key_length
= spr(c_pos_mess
, "s=(%d,%d), ",
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
csr_pos(sp
, LFT_M
, (TOP_M
- 2));
key_str
.key_string
= c_pos_mess
;
key_str
.key_length
= spr(c_pos_mess
, "o=(%d,%d), ",
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
key_str
.key_length
= spr(c_pos_mess
, "m=(%d,%d)",
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
cursor_on(&sp
->s_csr
.csr_p
);
sp
->s_plane
= fbbm_get_pixel(consfb
, parm
[0]);
sp
->s_bgcol
= fbbm_get_pixel(consfb
, parm
[1]);
if ((sp
->s_csr
.csr_attributes
& REVERSE
) ^
(sp
->s_term_mode
& DECSCNM
)) {
cursor_on(&sp
->s_csr
.csr_p
);
if (parm
[0] < 0 || consfb
->Mono
)
* what value is defined on pallet N?
bp
+= itoa(bm_pallet_read(parm
[0]), 10, bp
);
key_str
.key_length
= bp
- an_buf
;
key_str
.key_string
= an_buf
;
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
if (parm
[0] >= 0 && !consfb
->Mono
) {
| (unsigned) parm
[2] << 8
if (char_w
< font_w
) char_w
= font_w
;
if (char_h
< font_h
) char_h
= font_h
;
if (ch_pos
> char_h
- font_h
) {
ch_pos
= char_h
- font_h
;
if (rit_m
> (scr_w
- x_ofst
)/char_w
)
rit_m
= (scr_w
- x_ofst
)/char_w
;
if (btm_m
> (scr_h
- y_ofst
)/char_h
)
btm_m
= (scr_h
- y_ofst
)/char_h
;
sp
->s_region
.top_margin
= TOP_M
;
sp
->s_region
.btm_margin
= btm_m
;
font_r1
.extent
.x
= font_w
;
font_r1
.extent
.y
= font_h
;
font_r2
.extent
.x
= font_w
* 2;
font_r2
.extent
.y
= font_h
;
font_len1
= (font_w
+ 0x0f)>>4;
font_len2
= (font_w
*2 + 0x0f)>>4;
char_r1
.extent
.x
= char_w
;
char_r1
.extent
.y
= char_h
;
char_r2
.extent
.x
= char_w
* 2;
char_r2
.extent
.y
= char_h
;
csr_pos(sp
, sp
->s_csr
.csr_x
, sp
->s_csr
.csr_y
);
sp
->s_csr
.csr_p
.x
= (sp
->s_csr
.csr_x
- 1) * char_w
+ x_ofst
;
sp
->s_csr
.csr_p
.y
= (sp
->s_csr
.csr_y
- 1) * char_h
+ y_ofst
;
cursor_on(&sp
->s_csr
.csr_p
);
register u_int
*adx
= &ad
;
while ((c
= *fmt
++) != '%') {
static int active_buf
= 0;
* define the programable function keys and answer back message.
* the vt100 facilities do not contain this command!
* command sequence is as follows:
* "^[Pn|n1;n2;...;nmp" (normal mode)
* "^[Pn|n1;n2;...;nmP" (shift mode)
* "^[Pn|n1;n2;...;nmZ" (answer backe message)
* where, `n' denotes the decimal number asigned to function key,
* from `n1' to `nm' denote hexa number, finally,
* `p' , `E' or `Z' tells that the sequence has terminated.
* when the terminator is `Z', the function number `n' can be omitted,
* and even though the number is specified, there is no affection to
* there is a question: what strings are defined in programable function
* in order to anwer this question, another escape sequence has appended.
* command sequence is as follows:
* "^[Pn|n1;n2;...;nmr" (normal mode)
* "^[Pn|n1;n2;...;nmR" (shift mode)
if (in_str(c
, sp
->s_estp
->terminators
)) {
pf_define(pfn
, esc_bp
- esc_buf
+ active_buf
, c
);
sp
->s_current_stat
&= ~ESCAPE
;
/* buffering arguments */
if (bufc
< ESC_BUF_SIZ
) {
if (c
>= '0' && c
<= '9') {
*esc_bp
= *esc_bp
*10 + (c
- '0');
sp
->s_current_stat
&= ~ESCAPE
;
if (c
>= '0' && c
<= '9') {
*esc_bp
= *esc_bp
* 16 + (c
- '0');
} else if (c
>= 'a' && c
<= 'f') {
*esc_bp
= *esc_bp
* 16 + (c
- 'a' + 10);
} else if (c
>= 'A' && c
<= 'F') {
*esc_bp
= *esc_bp
* 16 + (c
- 'A' + 10);
sp
->s_current_stat
&= ~ESCAPE
;
pf_define(pfn
, length
, terminator
)
register Pfk_string
*pfk
= &pfk_str
;
register Key_string
*kys
= &pfk_str
.pfk_string
;
if (pfn
< 0 || pfn
> N_PFK
)
if (terminator
== 'i' || terminator
== 'I') {
pf_answer(pfn
, terminator
);
pfk
->pfk_num
= pfn
? pfn
: 1;
pfk
->pfk_shift
= (terminator
== 'p') ? PF_NORMAL
: PF_SHIFT
;
kys
->key_length
= length
;
kys
->key_string
= esc_buf
;
kbd_ioctl(SCC_KEYBOARD
, KIOCSETS
, pfk
);
* pf_answer(pfn, terminator)
* this routine answers what strings defined on pfn.
char def_seq
[ESC_BUF_SIZ
];
pf_answer(pfn
, terminator
)
register Pfk_string
*pfk
= &pfk_str
;
register Key_string
*kys
= &pfk_str
.pfk_string
;
register char *bp
= an_buf
;
register char *p
= def_seq
;
pfk
->pfk_num
= pfn
? pfn
: 1;
pfk
->pfk_shift
= (terminator
== 'i') ? PF_NORMAL
: PF_SHIFT
;
kys
->key_length
= ESC_BUF_SIZ
;
kys
->key_string
= def_seq
;
kbd_ioctl(SCC_KEYBOARD
, KIOCGETS
, pfk
);
length
= kys
->key_length
;
key_str
.key_length
= bp
- an_buf
;
key_str
.key_string
= an_buf
;
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, &key_str
);
bp
+= itoa(*p
++ & 0xff, 16, bp
);
for (j
= 0; (j
< 10) && (length
-- > 0); j
++) {
bp
+= itoa(*p
++ & 0xff, 16, bp
);
key_str
.key_length
= bp
- an_buf
;
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, (int *)&key_str
);
*bp
++ = (terminator
== 'i') ? 'r': 'R';
key_str
.key_length
= bp
- an_buf
;
kbd_ioctl(SCC_KEYBOARD
, KIOCBACK
, (int *)&key_str
);
* esc_ignore(sp) is not called ordinally work.
sp
->s_current_stat
&= ~ESCAPE
;
static char *nmr
= "0123456789abcdef";
* this routine converts binary to ascii decimal or hexa number
for (cnt
= mod
*mod
*mod
*mod
*mod
*mod
*mod
; cnt
> 0; cnt
/= mod
) {