* 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: vt100.c,v 4.300 91/06/09 06:14:56 root Rel41 $ SONY
* @(#)vt100.c 7.5 (Berkeley) %G%
#include <news3400/iop/framebuf.h>
#include <news3400/iop/kbreg.h>
#include <news3400/iop/keyboard.h>
#include <news3400/fb/fbdefs.h>
#include <news3400/bm/vt100.h>
#include <news3400/bm/bitmapif.h>
#define kbd_ioctl(chan, cmd, argp) { \
(*kb_ioctl)(chan, cmd, argp); \
#include <news3400/sio/scc.h>
extern Key_string key_str
;
static unsigned int first_code
;
struct cursor inner_buf_csr
;
char c_pos_mess
[C_MESS_SIZ
];
extern struct csr_buf local_csr_buf
;
#include "../../ubdev/msgio.h"
extern struct cons_devsw vt100_cons
;
extern kbd_profun_init();
unsigned short fbuf
[256];
register SCREEN
*sp
= &screen
;
sp
->s_term_mode
|= (SRM
|DECSCLM
|DECAWM
|DECARM
|DECCSR_ACTV
);
sp
->s_csr
.csr_p
.x
= x_ofst
;
sp
->s_csr
.csr_p
.y
= y_ofst
;
sp
->s_csr
.csr_attributes
= NORMALM
;
sp
->s_region
.top_margin
= TOP_M
;
sp
->s_region
.btm_margin
= btm_m
;
sp
->s_plane
= consfb
->planemask
;
for (i
= 0; i
< RIT_M_MAX
; i
++)
for (i
= 9; i
< RIT_M_MAX
; i
+=8)
inner_buf_tstat
= sp
->s_term_mode
& (DECOM
|DECAWM
);
local_csr_buf
.csr_number
= 1;
cursor_on(&sp
->s_csr
.csr_p
);
register struct fbdev
*cfb
= consfb
;
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
;
bell_len
= BELL_LEN_DFLT
;
extern char **ext_fnt_addr
;
while ((bitmap_use
= object_query(BITMAP
)) <= 0)
proc_create("auto_dimmer", auto_dimmer
, 401, 512, 0);
#define INIT_STRING "\033[42;1H"
vt100_write(0, INIT_STRING
, sizeof(INIT_STRING
) - 1);
int vt100_open(), vt100_read(), vt100_write(), vt100_ioctl();
vt100_cons
.open
= vt100_open
;
vt100_cons
.read
= vt100_read
;
vt100_cons
.write
= vt100_write
;
vt100_cons
.ioctl
= vt100_ioctl
;
#define DIMMER_INTERVAL 60 /* sec */
static int dimmer_stdport
;
register int dimm_counter
= DIM_CNT_DFLT
;
register int dimm_level
= 0;
ports
[0] = dimmer_stdport
= STDPORT
;
ports
[1] = port_create("auto_dimmer_sub");
register_interval(ports
[1], DIMMER_INTERVAL
);
select
= msg_select(2, ports
);
msg_recv(ports
[0], NULL
, &mode
, NULL
, 0);
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], 0);
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], dimm_level
);
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], dimm_level
);
msg_recv(ports
[1], NULL
, NULL
, NULL
, 0);
if (a_dim_on
&& (dimm_counter
-- <= 0)) {
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], dimm_level
);
static unsigned last_time
;
extern unsigned sys_time
;
diff
= sys_time
- last_time
;
if (diff
> DIMMER_INTERVAL
*HZ
|| diff
< 0) {
msg_send(dimmer_stdport
, 0, &mode
, sizeof(mode
), 0);
static int dimmer_counter
= DIM_CNT_DFLT
;
static int dim_level
= 0;
if (a_dim_on
&& (dimmer_counter
-- <= 0)) {
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], dim_level
);
dimmer_counter
= dim_cnt
;
timeout(auto_dimmer
, (caddr_t
) 0, 60 * hz
);
dimmer_counter
= dim_cnt
;
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], 0);
dimmer_counter
= dim_cnt
;
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], dim_level
);
dimmer_counter
= dim_cnt
;
for (i
= 0; i
< nfbdev
; i
++)
fbbm_set_dimmer(&fbdev
[i
], dim_level
);
* The routine `_putc(sp, c)' only prints a character c with the cursor
* attributes by using `copy_char(x, y, c, attributes)'.
* And when IRM (terminal insertion-replacement mode) is set, the characters
* righthand side of the cursor are shifted right and lost when they passed
* beyond the right margin.
* The position is specified by the sp pointer of the structure SCREEN.
if (sp
->s_term_mode
& IRM
) {
move_chars(sp
->s_csr
.csr_x
, sp
->s_csr
.csr_y
,
rit_m
- sp
->s_csr
.csr_x
- ((kanji
)? 1: 0),
sp
->s_csr
.csr_x
+ ((kanji
) ? 2: 1));
fpa
= sp
->s_csr
.csr_attributes
;
* Scroll up and down in the scroll region.
* New oriented line must be cleared with terminal mode, that is whether
* the screen is reverse mode or not.
scroll_up(top
, bottom
, revsw
, fcol
, bcol
)
move_lines(top
+ 1, bottom
- top
, top
);
clear_lines(bottom
, 1, revsw
, fcol
, bcol
);
scroll_down(top
, bottom
, revsw
, fcol
, bcol
)
move_lines(top
, bottom
- top
, top
+ 1);
clear_lines(top
, 1, revsw
, fcol
, bcol
);
* back_space(sp) moves cursor next to left at current cursor position.
* The cursor can not move beyond left or right margin.
register struct cursor
*spc
= &sp
->s_csr
;
if (spc
->csr_x
> LFT_M
) {
* next_tab_stop(sp) moves cursor to next tab stop.
for (i
= sp
->s_csr
.csr_x
+ 1; i
< rit_m
; i
++)
if (sp
->s_tab_pos
[i
] == 1)
sp
->s_csr
.csr_x
= min(i
, rit_m
);
sp
->s_csr
.csr_p
.x
= (sp
->s_csr
.csr_x
- 1) * char_w
+ x_ofst
;
cursor_on(&sp
->s_csr
.csr_p
);
* carriage_ret(sp) moves cursor at beginning of the current line.
sp
->s_csr
.csr_p
.x
= x_ofst
;
cursor_on(&sp
->s_csr
.csr_p
);
port
= port_create("port_cons_bell");
kbd_ioctl(port
, KIOCBELL
, &bell_len
);
kbd_ioctl(SCC_KEYBOARD
, KIOCBELL
, &bell_len
);
register SCREEN
*sp
= &screen
;
unsigned int sftjis_to_jis();
if (c
== 0x1b) { /* c == esc */
sp
->s_current_stat
|= ESCAPE
;
} else if (sp
->s_current_stat
& ESCAPE
) {
(*sp
->s_esc_handler
)(sp
, c
);
} else if (sp
->s_current_stat
& SKANJI
) {
c
= sftjis_to_jis(first_code
, c
);
if (sp
->s_current_stat
& JKANJI
) {
sp
->s_current_stat
|= JKANJI
;
sp
->s_current_stat
&= ~JKANJI
;
sp
->s_current_stat
&= ~SKANJI
;
} else if (sp
->s_current_stat
& EKANJI
) {
c
= (c
& 0x7f) | (first_code
<< 8);
if (sp
->s_current_stat
& JKANJI
) {
sp
->s_current_stat
|= JKANJI
;
sp
->s_current_stat
&= ~JKANJI
;
sp
->s_current_stat
&= ~EKANJI
;
} else if (sp
->s_current_stat
& JKANJI
) {
} else if (sp
->s_current_stat
& EKANA
) {
sp
->s_current_stat
&= ~EKANA
;
if (c
< 0x20) { /* control code */
case 0x08: /* back space */
case 0x09: /* tabulation */
case 0x0a: /* line feed */
case 0x0b: /* vertical feed */
case 0x0c: /* form feed */
case 0x0d: /* carriage return */
case 0x0e: /* shift out */
case 0x0f: /* shift in */
sp
->s_current_stat
&= ~ESCAPE
;
sp
->s_current_stat
|= ESCAPE
;
if ((c
>= JVR1S
&& c
<= JVR1E
) ||
(c
>= JVR2S
&& c
<= JVR2E
)) {
sp
->s_current_stat
|= SKANJI
;
if (c
>= CS1S
&& c
<= CS1E
) {
sp
->s_current_stat
|= EKANJI
;
sp
->s_current_stat
|= EKANA
;
cursor_on(&sp
->s_csr
.csr_p
);
* A printable character is printed in this routine by using
* Anyway, a character is printed in replacement mode or insertion
* mode and if the terminal is autowrap then it takes place wrapping
* and if cursor is bottom margin of the scroll region then it takes
* The escape sequence handling is another routine.
register struct cursor
*spc
= &(sp
->s_csr
);
register struct region
*spr
= &(sp
->s_region
);
if (spc
->csr_x
>= rit_m
||
((sp
->s_current_stat
& JKANJI
) && (spc
->csr_x
>= rit_m
- 1))) {
if (sp
->s_term_mode
& DECAWM
) {
if ((sp
->s_current_stat
& WRAP
) || (spc
->csr_x
== rit_m
&& sp
->s_current_stat
& JKANJI
)) {
if (spc
->csr_y
== spr
->btm_margin
) {
scroll_up(spr
->top_margin
,
sp
->s_term_mode
& DECSCNM
,
sp
->s_plane
, sp
->s_bgcol
);
cursor_on(&(spc
->csr_p
));
} else if (spc
->csr_y
< btm_m
) {
sp
->s_current_stat
|= WRAP
;
if (sp
->s_current_stat
& JKANJI
) {
if (spc
->csr_x
!= rit_m
) {
if (spc
->csr_x
< rit_m
) {
if (sp
->s_current_stat
& JKANJI
) {
spc
->csr_x
++; /* altered */
sp
->s_current_stat
&= ~WRAP
;