diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 1999-11-27 21:39:30 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 1999-11-27 21:39:30 +0000 |
commit | 280b873c0e10e85910c239eac02396260ce572be (patch) | |
tree | 33ae2b13005b46077838c6a110c024fdf7ff03f3 /sys/arch | |
parent | 95e3fe2683d8ccfcf4d0f32971b0f829b5be47e9 (diff) |
Shorten printf() strings, KNF, and fix a braino in a switch() statement.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/i386/isa/pcvt/pcvt_kbd.c | 142 | ||||
-rw-r--r-- | sys/arch/i386/isa/pcvt/pcvt_vtf.c | 2018 |
2 files changed, 1036 insertions, 1124 deletions
diff --git a/sys/arch/i386/isa/pcvt/pcvt_kbd.c b/sys/arch/i386/isa/pcvt/pcvt_kbd.c index 454030f28ce..26ea0c091ac 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_kbd.c +++ b/sys/arch/i386/isa/pcvt/pcvt_kbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcvt_kbd.c,v 1.30 1999/11/25 21:00:36 aaron Exp $ */ +/* $OpenBSD: pcvt_kbd.c,v 1.31 1999/11/27 21:39:29 aaron Exp $ */ /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. @@ -203,9 +203,8 @@ update_led(void) ledstate = LEDSTATE_UPDATE_PENDING; if (kbd_cmd(KEYB_C_LEDS) != 0) { - printf("Keyboard LED command timeout\n"); - splx(opri); - return; + printf("pcvt: kbd led cmd timeout\n"); + goto bail; } /* @@ -232,28 +231,27 @@ update_led(void) response1 = kbd_response(); if (kbd_cmd(new_ledstate) != 0) { - printf("Keyboard LED data timeout\n"); - splx(opri); - return; + printf("pcvt: kbd led data timeout\n"); + goto bail; } response2 = kbd_response(); if (response1 == KEYB_R_ACK && response2 == KEYB_R_ACK) ledstate = new_ledstate; - else - printf( - "Keyboard LED command not ACKed (responses %#x %#x)\n", - response1, response2); + else { + printf("pcvt: kbd led cmd not ack'd (resp %#x %#x)\n", + response1, response2); + } #if PCVT_UPDLED_LOSES_INTR if (lost_intr_timeout_queued) - untimeout (check_for_lost_intr, (void *)NULL); + untimeout(check_for_lost_intr, (void *)NULL); - timeout (check_for_lost_intr, (void *)NULL, hz); + timeout(check_for_lost_intr, (void *)NULL, hz); lost_intr_timeout_queued = 1; #endif /* PCVT_UPDLED_LOSES_INTR */ - } +bail: splx(opri); #endif /* !PCVT_NO_LED_UPDATE */ } @@ -268,26 +266,25 @@ settpmrate(int rate) opri = spltty(); tpmrate = rate & 0x7f; + if (kbd_cmd(KEYB_C_TYPEM) != 0) { - printf("Keyboard TYPEMATIC command timeout\n"); + printf("pcvt: kbd tpm cmd timeout\n"); goto fail; } response1 = kbd_response(); /* wait for ACK */ if (kbd_cmd(tpmrate) != 0) { - printf("Keyboard TYPEMATIC data timeout\n"); + printf("pcvt: kbd tpm data timeout\n"); goto fail; } response2 = kbd_response(); /* wait for ACK */ if (response1 != KEYB_R_ACK || response2 != KEYB_R_ACK) { - printf( - "Keyboard TYPEMATIC command not ACKed (responses %#x %#x)\n", + printf("pcvt: kbd tpm cmd not ack'd (resp %#x %#x)\n", response1, response2); } fail: splx(opri); - return; } /*---------------------------------------------------------------------------* @@ -302,11 +299,11 @@ kbd_wait_output() for (i = 100; i; i--) { if ((inb(CONTROLLER_CTRL) & STATUS_INPBF) == 0) { PCVT_KBD_DELAY(); - return 1; + return (1); } DELAY(1000); } - return 0; + return (0); } static inline int @@ -318,11 +315,11 @@ kbd_wait_input() for (i = 500; i; i--) { if ((inb(CONTROLLER_CTRL) & STATUS_OUTPBF) != 0) { PCVT_KBD_DELAY(); - return 1; + return (1); } DELAY(1000); } - return 0; + return (0); } static int @@ -361,7 +358,7 @@ kbd_response(void) return (-1); ch = inb(CONTROLLER_DATA); - return ch; + return (ch); } /*---------------------------------------------------------------------------* @@ -408,7 +405,7 @@ void doreset(void) /* Enable interrupts and keyboard, etc. */ if (kbc_8042cmd(CONTR_WRITE) != 0) - printf("pcvt: doreset() - timeout controller write command\n"); + printf("pcvt: timeout controller write cmd\n"); #if PCVT_USEKBDSEC /* security enabled */ @@ -430,7 +427,7 @@ void doreset(void) #endif /* PCVT_USEKBDSEC */ if (kbd_cmd(KBDINITCMD) != 0) - printf("pcvt: doreset() - timeout writing keyboard init command\n"); + printf("pcvt: timeout writing kbd init cmd\n"); /* * Discard any stale keyboard activity. The 0.1 boot code isn't @@ -450,21 +447,21 @@ void doreset(void) opri = spltty(); if (kbd_cmd(KEYB_C_RESET) != 0) - printf("pcvt: doreset() - keyboard reset command timeout\n"); + printf("pcvt: kbd reset cmd timeout\n"); /* Wait for the first response to reset and handle retries */ while ((response = kbd_response()) != KEYB_R_ACK) { if (response < 0) { if (!again) /* print message only once ! */ - printf("pcvt: doreset() - response != ack and response < 0 [one time only msg]\n"); + printf("pcvt: response != ack\n"); response = KEYB_R_RESEND; } if (response == KEYB_R_RESEND) { if (!again) /* print message only once ! */ - printf("pcvt: doreset() - got KEYB_R_RESEND response ... [one time only msg]\n"); + printf("pcvt: got KEYB_R_RESEND\n"); if (++again > PCVT_NONRESP_KEYB_TRY) { - printf("pcvt: doreset() - Caution - no PC keyboard detected!\n"); + printf("pcvt: no kbd detected\n"); keyboard_type = KB_UNKNOWN; splx(opri); return; @@ -472,7 +469,7 @@ void doreset(void) if ((kbd_cmd(KEYB_C_RESET) != 0) && (once == 0)) { once++; /* print message only once ! */ - printf("pcvt: doreset() - timeout for loop keyboard reset command [one time only msg]\n"); + printf("pcvt: timeout for loop\n"); } } } @@ -493,7 +490,7 @@ void doreset(void) seen_negative_response = 1; if (seen_negative_response && (wait_retries >= 10)) { - printf("pcvt: doreset() - response != OK and response < 0\n"); + printf("pcvt: response != OK\n"); /* * If KEYB_R_SELFOK never arrives, the loop will @@ -517,24 +514,22 @@ void doreset(void) if (!(response & COMMAND_PCSCAN)) { if (kbd_cmd(KEYB_C_SCANSET) != 0) - printf("pcvt: doreset() - keyboard SCANSET command timeout\n"); + printf("pcvt: kbd SCANSET cmd timeout\n"); else if (kbd_cmd(1) != 0) - printf("pcvt: doreset() - keyboard SCANSET data timeout\n"); + printf("pcvt: kbd SCANSET data timeout\n"); else - printf("pcvt: doreset() - keyboard set to XT mode\n"); + printf("pcvt: kbd set to XT mode\n"); } #endif - splx(opri); #if PCVT_KEYBDID query_kbd_id: - opri = spltty(); if (kbd_cmd(KEYB_C_ID) != 0) { - printf("pcvt: doreset() - timeout for keyboard ID command\n"); + printf("pcvt: timeout for kbd ID cmd\n"); keyboard_type = KB_UNKNOWN; } else { @@ -558,7 +553,7 @@ r_entry: break; default: - printf("\npcvt: doreset() - kbdid, response 2 = [%d]\n", response); + printf("pcvt: kbdid (resp 2 = %d)\n", response); keyboard_type = KB_UNKNOWN; break; } @@ -567,10 +562,8 @@ r_entry: goto r_entry; else if (response == -1) keyboard_type = KB_AT; - else { - printf("\npcvt: doreset() - kbdid, response 1 = [%d]\n", - response); - } + else + printf("pcvt: kbdid (resp 1 = %d)\n", response); } splx(opri); @@ -628,8 +621,9 @@ void ovlinit(int force) ovltbl[i].subc = ovltbl[i].suba = KBD_SUBT_STR; /* just strings .. */ } - for(i=0; i<=MAXKEYNUM; i++) + for(i = 0; i <= MAXKEYNUM; i++) key2ascii[i].type &= KBD_MASK; + ovlinitflag = 1; } } @@ -641,7 +635,7 @@ static int getokeydef(unsigned key, Ovl_tbl *thisdef) { if (key == 0 || key > MAXKEYNUM) - return EINVAL; + return (EINVAL); thisdef->keynum = key; thisdef->type = key2ascii[key].type; @@ -677,7 +671,6 @@ getokeydef(unsigned key, Ovl_tbl *thisdef) } /* deliver at least anything for ALTGR settings ... */ - if (key2ascii[key].unshift.subtype == STR) { bcopy((u_char *)(key2ascii[key].unshift.what.string), thisdef->altgr, CODE_SIZE); @@ -687,7 +680,7 @@ getokeydef(unsigned key, Ovl_tbl *thisdef) bcopy("", thisdef->altgr, CODE_SIZE); thisdef->suba = KBD_SUBT_FNC; } - return 0; + return (0); } /*---------------------------------------------------------------------------* @@ -699,14 +692,14 @@ getckeydef(unsigned key, Ovl_tbl *thisdef) u_short type = key2ascii[key].type; if (key > MAXKEYNUM) - return EINVAL; + return (EINVAL); if (type & KBD_OVERLOAD) *thisdef = ovltbl[key2ascii[key].ovlindex]; else getokeydef(key,thisdef); - return 0; + return (0); } /*---------------------------------------------------------------------------* @@ -730,7 +723,7 @@ xlatkey2ascii(U_short key) /* ignore the NON-KEY */ if (key == 0) - return 0; + return (0); /* get the current ASCII value */ getckeydef(key & 0x7F, &thisdef); @@ -744,10 +737,10 @@ xlatkey2ascii(U_short key) capchar[0] = altkpval; altkpflag = 0; altkpval = 0; - return capchar; + return (capchar); } } - return 0; + return (0); } switch (thisdef.type) { /* convert the keys */ @@ -842,7 +835,7 @@ xlatkey2ascii(U_short key) } else altkpflag = 0; - return 0; + return (0); } if (!vsp->num_lock) { @@ -925,7 +918,7 @@ xlatkey2ascii(U_short key) case KBD_CTL: case KBD_NONE: default: - return 0; + return (0); } } @@ -1050,7 +1043,7 @@ loop: else { if (noblock) - return NULL; + return (NULL); else goto loop; } @@ -1088,7 +1081,7 @@ loop: } if (noblock) - return NULL; + return (NULL); else goto loop; @@ -1180,7 +1173,7 @@ scroll_reset: } if (noblock == 31337) - return NULL; + return (NULL); if (key != 86) goto regular; @@ -1212,7 +1205,7 @@ scroll_reset: in_Debugger = 0; if (noblock) - return NULL; + return (NULL); else goto loop; } @@ -1274,7 +1267,7 @@ scroll_reset: if (!kbrepflag && key == kbd_lastkey && !kbd_status.breakseen) { if (noblock) - return NULL; + return (NULL); else goto loop; } @@ -1343,7 +1336,7 @@ scroll_reset: if (cp == NULL && !noblock) goto loop; - return cp; + return (cp); } /*---------------------------------------------------------------------------* @@ -1367,7 +1360,7 @@ rmkeydef(int key) register Ovl_tbl *ref; if (key == 0 || key > MAXKEYNUM) - return EINVAL; + return (EINVAL); if (key2ascii[key].type & KBD_OVERLOAD) { ref = &ovltbl[key2ascii[key].ovlindex]; @@ -1379,7 +1372,7 @@ rmkeydef(int key) ref->altgr[0] = 0; key2ascii[key].type &= KBD_MASK; } - return 0; + return (0); } /*---------------------------------------------------------------------------* @@ -1393,7 +1386,7 @@ setkeydef(Ovl_tbl *data) if ( data->keynum > MAXKEYNUM || (data->type & KBD_MASK) == KBD_BREAK || (data->type & KBD_MASK) > KBD_SHFTLOCK) - return EINVAL; + return (EINVAL); data->unshift[KBDMAXOVLKEYSIZE] = data->shift[KBDMAXOVLKEYSIZE] = @@ -1417,7 +1410,7 @@ setkeydef(Ovl_tbl *data) break; if (i == OVLTBL_SIZE) - return ENOSPC; /* no space, abuse of ENOSPC(!) */ + return (ENOSPC); /* no space, abuse of ENOSPC(!) */ } ovltbl[i] = *data; /* copy new data string */ @@ -1425,7 +1418,7 @@ setkeydef(Ovl_tbl *data) key2ascii[data->keynum].type |= KBD_OVERLOAD; /* mark key */ key2ascii[data->keynum].ovlindex = i; - return 0; + return (0); } /*---------------------------------------------------------------------------* @@ -1471,19 +1464,19 @@ kbdioctl(Dev_t dev, u_long cmd, caddr_t data, int flag) case KBDGCKEY: key = ((Ovl_tbl *)data)->keynum; - return getckeydef(key,(Ovl_tbl *)data); + return (getckeydef(key,(Ovl_tbl *)data)); case KBDSCKEY: key = ((Ovl_tbl *)data)->keynum; - return setkeydef((Ovl_tbl *)data); + return (setkeydef((Ovl_tbl *)data)); case KBDGOKEY: key = ((Ovl_tbl *)data)->keynum; - return getokeydef(key,(Ovl_tbl *)data); + return (getokeydef(key,(Ovl_tbl *)data)); case KBDRMKEY: key = *(int *)data; - return rmkeydef(key); + return (rmkeydef(key)); case KBDDEFAULT: ovlinit(1); @@ -1491,9 +1484,9 @@ kbdioctl(Dev_t dev, u_long cmd, caddr_t data, int flag) default: /* proceed with vga ioctls */ - return -1; + return (-1); } - return 0; + return (0); } /*---------------------------------------------------------------------------* @@ -1503,8 +1496,8 @@ static inline u_char iso2ibm(u_char c) { if (c < 0x80) - return c; - return iso2ibm437[c - 0x80]; + return (c); + return (iso2ibm437[c - 0x80]); } /*---------------------------------------------------------------------------* @@ -1582,8 +1575,7 @@ get_usl_keymap(keymap_t *map) case KBD_CTL: c = 9; - goto special; - special: +special: for(j = 0; j < NUM_STATES; j++) map->key[idx].map[j] = c; map->key[idx].spcl = 0xff; diff --git a/sys/arch/i386/isa/pcvt/pcvt_vtf.c b/sys/arch/i386/isa/pcvt/pcvt_vtf.c index 4300c2d7a94..68d70781957 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_vtf.c +++ b/sys/arch/i386/isa/pcvt/pcvt_vtf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcvt_vtf.c,v 1.10 1999/11/25 20:24:22 aaron Exp $ */ +/* $OpenBSD: pcvt_vtf.c,v 1.11 1999/11/27 21:39:29 aaron Exp $ */ /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. @@ -90,8 +90,7 @@ vt_stbm(struct video_state *svsp) { /* both 0 => scrolling region = entire screen */ - if((svsp->parms[0] == 0) && (svsp->parms[1] == 0)) - { + if ((svsp->parms[0] == 0) && (svsp->parms[1] == 0)) { svsp->cur_offset = 0; svsp->scrr_beg = 0; svsp->scrr_len = svsp->screen_rows; @@ -100,29 +99,29 @@ vt_stbm(struct video_state *svsp) return; } - if(svsp->parms[1] <= svsp->parms[0]) + if (svsp->parms[1] <= svsp->parms[0]) return; /* range parm 1 */ - if(svsp->parms[0] < 1) + if (svsp->parms[0] < 1) svsp->parms[0] = 1; - else if(svsp->parms[0] > svsp->screen_rows-1) - svsp->parms[0] = svsp->screen_rows-1; + else if (svsp->parms[0] > svsp->screen_rows - 1) + svsp->parms[0] = svsp->screen_rows - 1; /* range parm 2 */ - if(svsp->parms[1] < 2) + if (svsp->parms[1] < 2) svsp->parms[1] = 2; - else if(svsp->parms[1] > svsp->screen_rows) + else if (svsp->parms[1] > svsp->screen_rows) svsp->parms[1] = svsp->screen_rows; - svsp->scrr_beg = svsp->parms[0]-1; /* begin of scrolling region */ + svsp->scrr_beg = svsp->parms[0] - 1; /* begin of scrolling region */ svsp->scrr_len = svsp->parms[1] - svsp->parms[0] + 1; /* no of lines */ - svsp->scrr_end = svsp->parms[1]-1; + svsp->scrr_end = svsp->parms[1] - 1; /* cursor to first pos */ - if(svsp->m_om) + if (svsp->m_om) svsp->cur_offset = svsp->scrr_beg * svsp->maxcol; else svsp->cur_offset = 0; @@ -143,126 +142,122 @@ vt_sgr(struct video_state *svsp) setcolor = svsp->c_attr; - do - { - switch(svsp->parms[i++]) - { - case 0: /* reset to normal attributes */ - svsp->vtsgr = VT_NORMAL; - if (pcdisp) - setcolor = 0; - break; - - case 1: /* bold */ - svsp->vtsgr |= VT_BOLD; - if (pcdisp) { - if ((setcolor >> 8) == 0) - setcolor = (FG_LIGHTGREY << 8); - setcolor |= (FG_INTENSE << 8); - colortouched = 1; - } - break; + do { + switch(svsp->parms[i++]) { + case 0: /* reset to normal attributes */ + svsp->vtsgr = VT_NORMAL; + if (pcdisp) + setcolor = 0; + break; + + case 1: /* bold */ + svsp->vtsgr |= VT_BOLD; + if (pcdisp) { + if ((setcolor >> 8) == 0) + setcolor = (FG_LIGHTGREY << 8); + setcolor |= (FG_INTENSE << 8); + colortouched = 1; + } + break; - case 4: /* underline */ - svsp->vtsgr |= VT_UNDER; - break; + case 4: /* underline */ + svsp->vtsgr |= VT_UNDER; + break; - case 5: /* blinking */ - svsp->vtsgr |= VT_BLINK; - if (pcdisp) { - setcolor |= (FG_BLINK << 8); - colortouched = 1; - } - break; + case 5: /* blinking */ + svsp->vtsgr |= VT_BLINK; + if (pcdisp) { + setcolor |= (FG_BLINK << 8); + colortouched = 1; + } + break; - case 7: /* reverse */ - svsp->vtsgr |= VT_INVERSE; - if (pcdisp) { - if ((setcolor >> 8) == 0) - setcolor = (FG_LIGHTGREY << 8); - setcolor = (((setcolor>>8) & 0x88) | - ((((setcolor>>8) >> 4) | - ((setcolor>>8) << 4)) & 0x77)) << 8; - colortouched = 1; - } - break; + case 7: /* reverse */ + svsp->vtsgr |= VT_INVERSE; + if (pcdisp) { + if ((setcolor >> 8) == 0) + setcolor = (FG_LIGHTGREY << 8); + setcolor = (((setcolor >> 8) & 0x88) | + ((((setcolor >> 8) >> 4) | + ((setcolor >> 8) << 4)) & 0x77)) << 8; + colortouched = 1; + } + break; - case 22: /* not bold */ - svsp->vtsgr &= ~VT_BOLD; - if (pcdisp) { - setcolor &= ~(FG_INTENSE << 8); - colortouched = 1; - } - break; + case 22: /* not bold */ + svsp->vtsgr &= ~VT_BOLD; + if (pcdisp) { + setcolor &= ~(FG_INTENSE << 8); + colortouched = 1; + } + break; - case 24: /* not underlined */ - svsp->vtsgr &= ~VT_UNDER; - break; + case 24: /* not underlined */ + svsp->vtsgr &= ~VT_UNDER; + break; - case 25: /* not blinking */ - svsp->vtsgr &= ~VT_BLINK; - if (pcdisp) { - setcolor &= ~(FG_BLINK << 8); - colortouched = 1; - } - break; + case 25: /* not blinking */ + svsp->vtsgr &= ~VT_BLINK; + if (pcdisp) { + setcolor &= ~(FG_BLINK << 8); + colortouched = 1; + } + break; - case 27: /* not reverse */ - svsp->vtsgr &= ~VT_INVERSE; - if (pcdisp) { - setcolor = (((setcolor>>8) & 0x88) | - ((((setcolor>>8) >> 4) | - ((setcolor>>8) << 4)) & 0x77)) << 8; - colortouched = 1; - } - break; + case 27: /* not reverse */ + svsp->vtsgr &= ~VT_INVERSE; + if (pcdisp) { + setcolor = (((setcolor >> 8) & 0x88) | + ((((setcolor >> 8) >> 4) | + ((setcolor >> 8) << 4)) & 0x77)) << 8; + colortouched = 1; + } + break; - case 30: /* foreground colors */ - case 31: - case 32: - case 33: - case 34: - case 35: - case 36: - case 37: - if(color) - { - colortouched = 1; - setcolor &= ~(FG_MASK<<8); - setcolor |= ((fgansitopc[(svsp->parms[i-1]-30) & 7]) << 8); - if (pcdisp && svsp->vtsgr & VT_BOLD) + case 30: /* foreground colors */ + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + if (color) { + colortouched = 1; + setcolor &= ~(FG_MASK << 8); + setcolor |= ((fgansitopc[(svsp->parms[i - 1] - + 30) & 7]) << 8); + if (pcdisp && (svsp->vtsgr & VT_BOLD)) setcolor |= (FG_INTENSE << 8); - } - break; + } + break; - case 40: /* background colors */ - case 41: - case 42: - case 43: - case 44: - case 45: - case 46: - case 47: - if(color) - { - colortouched = 1; - setcolor &= ~(BG_MASK<<8); - setcolor |= ((bgansitopc[(svsp->parms[i-1]-40) & 7]) << 8); - } - break; + case 40: /* background colors */ + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + if (color) { + colortouched = 1; + setcolor &= ~(BG_MASK << 8); + setcolor |= ((bgansitopc[(svsp->parms[i - 1] - + 40) & 7]) << 8); + } + break; } - } - while(i <= svsp->parmi); - if(color) - { - if(colortouched) + } while (i <= svsp->parmi); + + if (color) { + if (colortouched) svsp->c_attr = setcolor; else svsp->c_attr = ((sgr_tab_color[svsp->vtsgr]) << 8); } - else - { - if(adaptor_type == MDA_ADAPTOR) + else { + if (adaptor_type == MDA_ADAPTOR) svsp->c_attr = ((sgr_tab_imono[svsp->vtsgr]) << 8); else svsp->c_attr = ((sgr_tab_mono[svsp->vtsgr]) << 8); @@ -318,16 +313,16 @@ vt_cuf(struct video_state *svsp) { register int p = svsp->parms[0]; - if(svsp->col == ((svsp->maxcol)-1)) /* already at right margin */ + if (svsp->col == ((svsp->maxcol) - 1)) /* already at rt margin */ return; - if(p <= 0) /* parameter min = 1 */ + if (p <= 0) /* parameter min = 1 */ p = 1; - else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */ - p = ((svsp->maxcol)-1); + else if (p > ((svsp->maxcol) - 1)) /* parameter max = 79 */ + p = ((svsp->maxcol) - 1); - if((svsp->col + p) > ((svsp->maxcol)-1))/* not more than right margin */ - p = ((svsp->maxcol)-1) - svsp->col; + if ((svsp->col + p) > ((svsp->maxcol) - 1)) /* not more than rt margin */ + p = ((svsp->maxcol) - 1) - svsp->col; svsp->cur_offset += p; svsp->col += p; @@ -341,15 +336,15 @@ vt_cub(struct video_state *svsp) { register int p = svsp->parms[0]; - if(svsp->col == 0) /* already at left margin ? */ + if (svsp->col == 0) /* already at left margin ? */ return; - if(p <= 0) /* parameter min = 1 */ + if (p <= 0) /* parameter min = 1 */ p = 1; - else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */ - p = ((svsp->maxcol)-1); + else if (p > ((svsp->maxcol) - 1)) /* parameter max = 79 */ + p = ((svsp->maxcol) - 1); - if((svsp->col - p) <= 0) /* not more than left margin */ + if ((svsp->col - p) <= 0) /* not more than left margin */ p = svsp->col; svsp->cur_offset -= p; @@ -362,26 +357,23 @@ vt_cub(struct video_state *svsp) void vt_clreos(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: - fillw(user_attr | ' ', - (caddr_t)(svsp->Crtat + svsp->cur_offset), - svsp->Crtat + - (svsp->maxcol * svsp->screen_rows) - - (svsp->Crtat + svsp->cur_offset)); - break; - - case 1: - fillw(user_attr | ' ', (caddr_t)(svsp->Crtat), - svsp->Crtat + svsp->cur_offset - - svsp->Crtat + 1 ); - break; - - case 2: - fillw(user_attr | ' ', (caddr_t)(svsp->Crtat), - svsp->maxcol * svsp->screen_rows); - break; + switch(svsp->parms[0]) { + case 0: + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + svsp->cur_offset), + svsp->Crtat + (svsp->maxcol * svsp->screen_rows) - + (svsp->Crtat + svsp->cur_offset)); + break; + + case 1: + fillw(user_attr | ' ', (caddr_t)(svsp->Crtat), + svsp->Crtat + svsp->cur_offset - svsp->Crtat + 1); + break; + + case 2: + fillw(user_attr | ' ', (caddr_t)(svsp->Crtat), + svsp->maxcol * svsp->screen_rows); + break; } } @@ -391,25 +383,24 @@ vt_clreos(struct video_state *svsp) void vt_clreol(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: - fillw(user_attr | ' ', - (caddr_t)(svsp->Crtat + svsp->cur_offset), - svsp->maxcol-svsp->col); - break; - - case 1: - fillw(user_attr | ' ',(caddr_t) - (svsp->Crtat + svsp->cur_offset - svsp->col), - svsp->col + 1); - break; - - case 2: - fillw(user_attr | ' ',(caddr_t) - (svsp->Crtat + svsp->cur_offset - svsp->col), - svsp->maxcol); - break; + switch(svsp->parms[0]) { + case 0: + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + svsp->cur_offset), + svsp->maxcol - svsp->col); + break; + + case 1: + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + svsp->cur_offset - svsp->col), + svsp->col + 1); + break; + + case 2: + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + svsp->cur_offset - svsp->col), + svsp->maxcol); + break; } } @@ -419,59 +410,53 @@ vt_clreol(struct video_state *svsp) void vt_curadr(struct video_state *svsp) { - if(svsp->m_om) /* relative to scrolling region */ - { - if((svsp->parms[0] == 0) && (svsp->parms[1] == 0)) - { + if (svsp->m_om) { /* relative to scrolling region */ + if ((svsp->parms[0] == 0) && (svsp->parms[1] == 0)) { svsp->cur_offset = svsp->scrr_beg * svsp->maxcol; svsp->col = 0; svsp->abs_write = 0; return; } - if(svsp->parms[0] <= 0) + if (svsp->parms[0] <= 0) svsp->parms[0] = 1; - else if(svsp->parms[0] > svsp->scrr_len) + else if (svsp->parms[0] > svsp->scrr_len) svsp->parms[0] = svsp->scrr_len; - if(svsp->parms[1] <= 0 ) + if (svsp->parms[1] <= 0 ) svsp->parms[1] = 1; - if(svsp->parms[1] > svsp->maxcol) + if (svsp->parms[1] > svsp->maxcol) svsp->parms[1] = svsp->maxcol; svsp->cur_offset = (svsp->scrr_beg * svsp->maxcol) + - ((svsp->parms[0] - 1) * svsp->maxcol) + - svsp->parms[1] - 1; + ((svsp->parms[0] - 1) * svsp->maxcol) + svsp->parms[1] - 1; svsp->col = svsp->parms[1] - 1; svsp->abs_write = 0; } - else /* relative to screen start */ - { - if((svsp->parms[0] == 0) && (svsp->parms[1] == 0)) - { + else { /* relative to screen start */ + if ((svsp->parms[0] == 0) && (svsp->parms[1] == 0)) { svsp->cur_offset = 0; svsp->col = 0; svsp->abs_write = 0; return; } - if(svsp->parms[0] <= 0) + if (svsp->parms[0] <= 0) svsp->parms[0] = 1; - else if(svsp->parms[0] > svsp->screen_rows) + else if (svsp->parms[0] > svsp->screen_rows) svsp->parms[0] = svsp->screen_rows; - if(svsp->parms[1] <= 0 ) + if (svsp->parms[1] <= 0 ) svsp->parms[1] = 1; - if(svsp->parms[1] > svsp->maxcol) /* col */ + if (svsp->parms[1] > svsp->maxcol) /* col */ svsp->parms[1] = svsp->maxcol; - svsp->cur_offset = (((svsp->parms[0]-1)*svsp->maxcol) + - (svsp->parms[1]-1)); + svsp->cur_offset = (((svsp->parms[0] - 1) * svsp->maxcol) + + (svsp->parms[1] - 1)); svsp->col = svsp->parms[1]-1; if (svsp->cur_offset >= ((svsp->scrr_beg + svsp->scrr_len + 1) * svsp->maxcol)) - svsp->abs_write = 1; else svsp->abs_write = 0; @@ -485,7 +470,7 @@ void vt_ris(struct video_state *svsp) { fillw(user_attr | ' ', - (caddr_t)(svsp->Crtat), svsp->maxcol * svsp->screen_rows); + (caddr_t)(svsp->Crtat), svsp->maxcol * svsp->screen_rows); svsp->cur_offset = 0; /* cursor upper left corner */ svsp->col = 0; svsp->row = 0; @@ -508,15 +493,13 @@ vt_str(struct video_state *svsp) svsp->state = STATE_INIT; /* initial state */ svsp->dis_fnc = 0; /* display functions reset */ - svsp->sc_flag = 0; /* save cursor position */ - svsp->transparent = 0; /* enable control code processing */ + svsp->transparent = 0; /* enable ctrl code processing*/ svsp->C1_ctls = 0; /* but only for C0 codes */ svsp->sevenbit = 0; /* data path 8 bits wide */ - for(i = 0; i < MAXTAB; i++) /* setup tabstops */ - { - if(!(i % 8)) + for (i = 0; i < MAXTAB; i++) { /* setup tabstops */ + if (!(i % 8)) svsp->tab_stops[i] = 1; else svsp->tab_stops[i] = 0; @@ -535,14 +518,13 @@ vt_str(struct video_state *svsp) svsp->scroll_lock = 0; /* reset keyboard modes */ svsp->caps_lock = 0; - svsp->ckm = 1; /* cursor key mode = "normal" ... */ + svsp->ckm = 1; /* cursor key mode="normal" */ svsp->scrr_beg = 0; /* start of scrolling region */ - svsp->scrr_len = svsp->screen_rows; /* no. of lines in scrolling region */ + svsp->scrr_len = svsp->screen_rows; /* #lines in scrolling region */ svsp->abs_write = 0; /* scrr is complete screen */ svsp->scrr_end = svsp->scrr_len - 1; - if(adaptor_type == EGA_ADAPTOR || adaptor_type == VGA_ADAPTOR) - { + if (adaptor_type == EGA_ADAPTOR || adaptor_type == VGA_ADAPTOR) { svsp->G0 = cse_ascii; /* G0 = ascii */ svsp->G1 = cse_ascii; /* G1 = ascii */ svsp->G2 = cse_supplemental; /* G2 = supplemental */ @@ -550,8 +532,7 @@ vt_str(struct video_state *svsp) svsp->GL = svsp->G0; /* GL = G0 */ svsp->GR = svsp->G2; /* GR = G2 */ } - else - { + else { svsp->G0 = csd_ascii; /* G0 = ascii */ svsp->G1 = csd_ascii; /* G1 = ascii */ svsp->G2 = csd_supplemental; /* G2 = supplemental */ @@ -587,7 +568,7 @@ vt_ri(struct video_state *svsp) void vt_ind(struct video_state *svsp) { - if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol)) + if (svsp->cur_offset < (svsp->scrr_end * svsp->maxcol)) svsp->cur_offset += svsp->maxcol; else roll_up(svsp, 1); @@ -599,13 +580,11 @@ vt_ind(struct video_state *svsp) void vt_nel(struct video_state *svsp) { - if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol)) - { + if (svsp->cur_offset < (svsp->scrr_end * svsp->maxcol)) { svsp->cur_offset += (svsp->maxcol-svsp->col); svsp->col = 0; } - else - { + else { roll_up(svsp, 1); svsp->cur_offset -= svsp->col; svsp->col = 0; @@ -618,54 +597,53 @@ vt_nel(struct video_state *svsp) void vt_set_dec_priv_qm(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: /* error, ignored */ - case 1: /* CKM - cursor key mode */ - svsp->ckm = 1; - break; - - case 2: /* ANM - ansi/vt52 mode */ - break; - - case 3: /* COLM - column mode */ - vt_col(svsp, SCR_COL132); - break; - - case 4: /* SCLM - scrolling mode */ - case 5: /* SCNM - screen mode */ - break; - - case 6: /* OM - origin mode */ - svsp->m_om = 1; - break; - - case 7: /* AWM - auto wrap mode */ - svsp->m_awm = 1; - break; - - case 8: /* ARM - auto repeat mode */ - kbrepflag = 1; - break; - - case 9: /* INLM - interlace mode */ - case 10: /* EDM - edit mode */ - case 11: /* LTM - line transmit mode */ - case 12: /* */ - case 13: /* SCFDM - space compression / field delimiting */ - case 14: /* TEM - transmit execution mode */ - case 15: /* */ - case 16: /* EKEM - edit key execution mode */ - break; - - case 25: /* TCEM - text cursor enable mode */ - if(vsp == svsp) - sw_cursor(1); /* cursor on */ - svsp->cursor_on = 1; - break; - - case 42: /* NRCM - 7bit NRC characters */ - break; + switch (svsp->parms[0]) { + case 0: /* error, ignored */ + case 1: /* CKM - cursor key mode */ + svsp->ckm = 1; + break; + + case 2: /* ANM - ansi/vt52 mode */ + break; + + case 3: /* COLM - column mode */ + vt_col(svsp, SCR_COL132); + break; + + case 4: /* SCLM - scrolling mode */ + case 5: /* SCNM - screen mode */ + break; + + case 6: /* OM - origin mode */ + svsp->m_om = 1; + break; + + case 7: /* AWM - auto wrap mode */ + svsp->m_awm = 1; + break; + + case 8: /* ARM - auto repeat mode */ + kbrepflag = 1; + break; + + case 9: /* INLM - interlace mode */ + case 10: /* EDM - edit mode */ + case 11: /* LTM - line transmit mode */ + case 12: /* */ + case 13: /* SCFDM - space compression / field delimiting */ + case 14: /* TEM - transmit execution mode */ + case 15: /* */ + case 16: /* EKEM - edit key execution mode */ + break; + + case 25: /* TCEM - text cursor enable mode */ + if (vsp == svsp) + sw_cursor(1); /* cursor on */ + svsp->cursor_on = 1; + break; + + case 42: /* NRCM - 7bit NRC characters */ + break; } } @@ -675,54 +653,53 @@ vt_set_dec_priv_qm(struct video_state *svsp) void vt_reset_dec_priv_qm(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: /* error, ignored */ - case 1: /* CKM - cursor key mode */ - svsp->ckm = 0; - break; - - case 2: /* ANM - ansi/vt52 mode */ - break; - - case 3: /* COLM - column mode */ - vt_col(svsp, SCR_COL80); - break; - - case 4: /* SCLM - scrolling mode */ - case 5: /* SCNM - screen mode */ - break; - - case 6: /* OM - origin mode */ - svsp->m_om = 0; - break; - - case 7: /* AWM - auto wrap mode */ - svsp->m_awm = 0; - break; - - case 8: /* ARM - auto repeat mode */ - kbrepflag = 0; - break; - - case 9: /* INLM - interlace mode */ - case 10: /* EDM - edit mode */ - case 11: /* LTM - line transmit mode */ - case 12: /* */ - case 13: /* SCFDM - space compression / field delimiting */ - case 14: /* TEM - transmit execution mode */ - case 15: /* */ - case 16: /* EKEM - edit key execution mode */ - break; - - case 25: /* TCEM - text cursor enable mode */ - if(vsp == svsp) - sw_cursor(0); /* cursor off */ - svsp->cursor_on = 0; - break; - - case 42: /* NRCM - 7bit NRC characters */ - break; + switch (svsp->parms[0]) { + case 0: /* error, ignored */ + case 1: /* CKM - cursor key mode */ + svsp->ckm = 0; + break; + + case 2: /* ANM - ansi/vt52 mode */ + break; + + case 3: /* COLM - column mode */ + vt_col(svsp, SCR_COL80); + break; + + case 4: /* SCLM - scrolling mode */ + case 5: /* SCNM - screen mode */ + break; + + case 6: /* OM - origin mode */ + svsp->m_om = 0; + break; + + case 7: /* AWM - auto wrap mode */ + svsp->m_awm = 0; + break; + + case 8: /* ARM - auto repeat mode */ + kbrepflag = 0; + break; + + case 9: /* INLM - interlace mode */ + case 10: /* EDM - edit mode */ + case 11: /* LTM - line transmit mode */ + case 12: /* */ + case 13: /* SCFDM - space compression / field delimiting */ + case 14: /* TEM - transmit execution mode */ + case 15: /* */ + case 16: /* EKEM - edit key execution mode */ + break; + + case 25: /* TCEM - text cursor enable mode */ + if (vsp == svsp) + sw_cursor(0); /* cursor off */ + svsp->cursor_on = 0; + break; + + case 42: /* NRCM - 7bit NRC characters */ + break; } } @@ -732,36 +709,35 @@ vt_reset_dec_priv_qm(struct video_state *svsp) void vt_set_ansi(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: /* error, ignored */ - case 1: /* GATM - guarded area transfer mode */ - case 2: /* KAM - keyboard action mode */ - case 3: /* CRM - Control Representation mode */ - break; - - case 4: /* IRM - insert replacement mode */ - svsp->irm = 1; /* Insert mode */ - break; - - case 5: /* SRTM - status report transfer mode */ - case 6: /* ERM - erasue mode */ - case 7: /* VEM - vertical editing mode */ - case 10: /* HEM - horizontal editing mode */ - case 11: /* PUM - position unit mode */ - case 12: /* SRM - send-receive mode */ - case 13: /* FEAM - format effector action mode */ - case 14: /* FETM - format effector transfer mode */ - case 15: /* MATM - multiple area transfer mode */ - case 16: /* TTM - transfer termination */ - case 17: /* SATM - selected area transfer mode */ - case 18: /* TSM - tabulation stop mode */ - case 19: /* EBM - editing boundary mode */ - break; - - case 20: /* LNM - line feed / newline mode */ - svsp->lnm = 1; - break; + switch (svsp->parms[0]) { + case 0: /* error, ignored */ + case 1: /* GATM - guarded area transfer mode */ + case 2: /* KAM - keyboard action mode */ + case 3: /* CRM - Control Representation mode */ + break; + + case 4: /* IRM - insert replacement mode */ + svsp->irm = 1; /* Insert mode */ + break; + + case 5: /* SRTM - status report transfer mode */ + case 6: /* ERM - erasue mode */ + case 7: /* VEM - vertical editing mode */ + case 10: /* HEM - horizontal editing mode */ + case 11: /* PUM - position unit mode */ + case 12: /* SRM - send-receive mode */ + case 13: /* FEAM - format effector action mode */ + case 14: /* FETM - format effector transfer mode */ + case 15: /* MATM - multiple area transfer mode */ + case 16: /* TTM - transfer termination */ + case 17: /* SATM - selected area transfer mode */ + case 18: /* TSM - tabulation stop mode */ + case 19: /* EBM - editing boundary mode */ + break; + + case 20: /* LNM - line feed / newline mode */ + svsp->lnm = 1; + break; } } @@ -771,36 +747,35 @@ vt_set_ansi(struct video_state *svsp) void vt_reset_ansi(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: /* error, ignored */ - case 1: /* GATM - guarded area transfer mode */ - case 2: /* KAM - keyboard action mode */ - case 3: /* CRM - Control Representation mode */ - break; - - case 4: /* IRM - insert replacement mode */ - svsp->irm = 0; /* Replace mode */ - break; - - case 5: /* SRTM - status report transfer mode */ - case 6: /* ERM - erasue mode */ - case 7: /* VEM - vertical editing mode */ - case 10: /* HEM - horizontal editing mode */ - case 11: /* PUM - position unit mode */ - case 12: /* SRM - send-receive mode */ - case 13: /* FEAM - format effector action mode */ - case 14: /* FETM - format effector transfer mode */ - case 15: /* MATM - multiple area transfer mode */ - case 16: /* TTM - transfer termination */ - case 17: /* SATM - selected area transfer mode */ - case 18: /* TSM - tabulation stop mode */ - case 19: /* EBM - editing boundary mode */ - break; - - case 20: /* LNM - line feed / newline mode */ - svsp->lnm = 0; - break; + switch (svsp->parms[0]) { + case 0: /* error, ignored */ + case 1: /* GATM - guarded area transfer mode */ + case 2: /* KAM - keyboard action mode */ + case 3: /* CRM - Control Representation mode */ + break; + + case 4: /* IRM - insert replacement mode */ + svsp->irm = 0; /* Replace mode */ + break; + + case 5: /* SRTM - status report transfer mode */ + case 6: /* ERM - erasue mode */ + case 7: /* VEM - vertical editing mode */ + case 10: /* HEM - horizontal editing mode */ + case 11: /* PUM - position unit mode */ + case 12: /* SRM - send-receive mode */ + case 13: /* FEAM - format effector action mode */ + case 14: /* FETM - format effector transfer mode */ + case 15: /* MATM - multiple area transfer mode */ + case 16: /* TTM - transfer termination */ + case 17: /* SATM - selected area transfer mode */ + case 18: /* TSM - tabulation stop mode */ + case 19: /* EBM - editing boundary mode */ + break; + + case 20: /* LNM - line feed / newline mode */ + svsp->lnm = 0; + break; } } @@ -812,11 +787,10 @@ vt_clrtab(struct video_state *svsp) { int i; - if(svsp->parms[0] == 0) + if (svsp->parms[0] == 0) svsp->tab_stops[svsp->col] = 0; - else if(svsp->parms[0] == 3) - { - for(i=0; i<MAXTAB; i++) + else if (svsp->parms[0] == 3) { + for (i = 0; i < MAXTAB; i++) svsp->tab_stops[i] = 0; } } @@ -850,8 +824,7 @@ vt_sc(struct video_state *svsp) void vt_rc(struct video_state *svsp) { - if(svsp->sc_flag == 1) - { + if (svsp->sc_flag == 1) { svsp->sc_flag = 0; svsp->row = svsp->sc_row; svsp->col = svsp->sc_col; @@ -879,25 +852,21 @@ vt_designate(struct video_state *svsp) u_short *ctp = NULL; u_char ch; - if(svsp->whichi == 1) + if (svsp->whichi == 1) ch = svsp->which[0]; - else - { + else { int i; - if(svsp->dld_id[0] == '\0') + if (svsp->dld_id[0] == '\0') return; - if(!(((adaptor_type == EGA_ADAPTOR) || + if (!(((adaptor_type == EGA_ADAPTOR) || (adaptor_type == VGA_ADAPTOR)) && (vgacs[svsp->vga_charset].secondloaded))) - { return; - } - for(i = (svsp->whichi)-1; i >= 0; i--) - { - if(svsp->which[i] != svsp->dld_id[i]) + for (i = (svsp->whichi) - 1; i >= 0; i--) { + if (svsp->which[i] != svsp->dld_id[i]) return; } #ifdef HAVECSE_DOWNLOADABLE @@ -907,11 +876,9 @@ vt_designate(struct video_state *svsp) return; } - if(((adaptor_type == EGA_ADAPTOR) || (adaptor_type == VGA_ADAPTOR)) && - (vgacs[svsp->vga_charset].secondloaded)) - { - if((ch == svsp->dld_id[0]) && (svsp->dld_id[1] == '\0')) - { + if (((adaptor_type == EGA_ADAPTOR) || (adaptor_type == VGA_ADAPTOR)) && + (vgacs[svsp->vga_charset].secondloaded)) { + if ((ch == svsp->dld_id[0]) && (svsp->dld_id[1] == '\0')) { #ifdef HAVECSE_DOWNLOADABLE ctp = cse_downloadable; swcsp(svsp, ctp); @@ -919,288 +886,283 @@ vt_designate(struct video_state *svsp) return; } - switch(ch) - { - case 'A': /* British or ISO-Latin-1 */ - switch(svsp->state) - { - case STATE_BROPN: /* designate G0 */ - case STATE_BRCLO: /* designate G1 */ - case STATE_STAR: /* designate G2 */ - case STATE_PLUS: /* designate G3 */ + switch (ch) { + case 'A': /* British or ISO-Latin-1 */ + switch (svsp->state) { + case STATE_BROPN: /* designate G0 */ + case STATE_BRCLO: /* designate G1 */ + case STATE_STAR: /* designate G2 */ + case STATE_PLUS: /* designate G3 */ #ifdef HAVECSE_BRITISH - ctp = cse_british; + ctp = cse_british; #endif - break; + break; - case STATE_MINUS: /* designate G1 (96)*/ - case STATE_DOT: /* designate G2 (96)*/ - case STATE_SLASH: /* designate G3 (96)*/ + case STATE_MINUS: /* designate G1 (96)*/ + case STATE_DOT: /* designate G2 (96)*/ + case STATE_SLASH: /* designate G3 (96)*/ #ifdef HAVECSE_ISOLATIN - ctp = cse_isolatin; + ctp = cse_isolatin; #endif - break; - } break; + } + break; - case 'B': /* USASCII */ + case 'B': /* USASCII */ #ifdef HAVECSE_ASCII - ctp = cse_ascii; + ctp = cse_ascii; #endif - break; + break; - case 'C': /* Finnish */ - case '5': /* Finnish */ + case 'C': /* Finnish */ + case '5': /* Finnish */ #ifdef HAVECSE_FINNISH - ctp = cse_finnish; + ctp = cse_finnish; #endif - break; + break; - case 'E': /* Norwegian/Danish */ - case '6': /* Norwegian/Danish */ + case 'E': /* Norwegian/Danish */ + case '6': /* Norwegian/Danish */ #ifdef HAVECSE_NORWEGIANDANISH - ctp = cse_norwegiandanish; + ctp = cse_norwegiandanish; #endif - break; + break; - case 'H': /* Swedish */ - case '7': /* Swedish */ + case 'H': /* Swedish */ + case '7': /* Swedish */ #ifdef HAVECSE_SWEDISH - ctp = cse_swedish; + ctp = cse_swedish; #endif - break; + break; - case 'K': /* German */ + case 'K': /* German */ #ifdef HAVECSE_GERMAN - ctp = cse_german; + ctp = cse_german; #endif - break; + break; - case 'Q': /* French Canadien */ + case 'Q': /* French Canadien */ #ifdef HAVECSE_FRENCHCANADA - ctp = cse_frenchcanada; + ctp = cse_frenchcanada; #endif - break; + break; - case 'R': /* French */ + case 'R': /* French */ #ifdef HAVECSE_FRENCH - ctp = cse_french; + ctp = cse_french; #endif - break; + break; - case 'X': /* KOI8 hack */ + case 'X': /* KOI8 hack */ #ifdef HAVECSE_KOI8 - ctp = cse_koi8; + ctp = cse_koi8; #endif - break; + break; - case 'Y': /* Italian */ + case 'Y': /* Italian */ #ifdef HAVECSE_ITALIAN - ctp = cse_italian; + ctp = cse_italian; #endif - break; + break; - case 'Z': /* Spanish */ + case 'Z': /* Spanish */ #ifdef HAVECSE_SPANISH - ctp = cse_spanish; + ctp = cse_spanish; #endif - break; + break; - case '0': /* special graphics */ + case '0': /* special graphics */ #ifdef HAVECSE_SPECIAL - ctp = cse_special; + ctp = cse_special; #endif - break; + break; - case '1': /* alternate ROM */ + case '1': /* alternate ROM */ #ifdef HAVECSE_ALTERNATEROM1 - ctp = cse_alternaterom1; + ctp = cse_alternaterom1; #endif - break; + break; - case '2': /* alt ROM, spec graphics */ + case '2': /* alt ROM, spec graphics */ #ifdef HAVECSE_ALTERNATEROM2 - ctp = cse_alternaterom2; + ctp = cse_alternaterom2; #endif - break; + break; - case '3': /* HP Roman 8, upper 128 chars*/ + case '3': /* HP Roman 8, upper 128 chars*/ #ifdef HAVECSE_ROMAN8 - ctp = cse_roman8; + ctp = cse_roman8; #endif - break; + break; - case '4': /* Dutch */ + case '4': /* Dutch */ #ifdef HAVECSE_DUTCH - ctp = cse_dutch; + ctp = cse_dutch; #endif - break; + break; - case '<': /* DEC Supplemental */ + case '<': /* DEC Supplemental */ #ifdef HAVECSE_SUPPLEMENTAL - ctp = cse_supplemental; + ctp = cse_supplemental; #endif - break; + break; - case '=': /* Swiss */ + case '=': /* Swiss */ #ifdef HAVECSE_SWISS - ctp = cse_swiss; + ctp = cse_swiss; #endif - break; + break; - case '>': /* DEC Technical */ + case '>': /* DEC Technical */ #ifdef HAVECSE_TECHNICAL - ctp = cse_technical; + ctp = cse_technical; #endif - break; + break; - default: - break; + default: + break; } } - else - { - switch(ch) - { - case 'A': /* British or ISO-Latin-1 */ - switch(svsp->state) - { - case STATE_BROPN: /* designate G0 */ - case STATE_BRCLO: /* designate G1 */ - case STATE_STAR: /* designate G2 */ - case STATE_PLUS: /* designate G3 */ + else { + switch (ch) { + case 'A': /* British or ISO-Latin-1 */ + switch (svsp->state) { + case STATE_BROPN: /* designate G0 */ + case STATE_BRCLO: /* designate G1 */ + case STATE_STAR: /* designate G2 */ + case STATE_PLUS: /* designate G3 */ #ifdef HAVECSD_BRITISH - ctp = csd_british; + ctp = csd_british; #endif - break; + break; - case STATE_MINUS: /* designate G1 (96)*/ - case STATE_DOT: /* designate G2 (96)*/ - case STATE_SLASH: /* designate G3 (96)*/ + case STATE_MINUS: /* designate G1 (96)*/ + case STATE_DOT: /* designate G2 (96)*/ + case STATE_SLASH: /* designate G3 (96)*/ #ifdef HAVECSD_ISOLATIN - ctp = csd_isolatin; + ctp = csd_isolatin; #endif - break; - } break; + } + break; - case 'B': /* USASCII */ + case 'B': /* USASCII */ #ifdef HAVECSD_ASCII - ctp = csd_ascii; - pcdisp_special = 0; + ctp = csd_ascii; + pcdisp_special = 0; #endif - break; + break; - case 'C': /* Finnish */ - case '5': /* Finnish */ + case 'C': /* Finnish */ + case '5': /* Finnish */ #ifdef HAVECSD_FINNISH - ctp = csd_finnish; + ctp = csd_finnish; #endif - break; + break; - case 'E': /* Norwegian/Danish */ - case '6': /* Norwegian/Danish */ + case 'E': /* Norwegian/Danish */ + case '6': /* Norwegian/Danish */ #ifdef HAVECSD_NORWEGIANDANISH - ctp = csd_norwegiandanish; + ctp = csd_norwegiandanish; #endif - break; + break; - case 'H': /* Swedish */ - case '7': /* Swedish */ + case 'H': /* Swedish */ + case '7': /* Swedish */ #ifdef HAVECSD_SWEDISH - ctp = csd_swedish; + ctp = csd_swedish; #endif - break; + break; - case 'K': /* German */ + case 'K': /* German */ #ifdef HAVECSD_GERMAN - ctp = csd_german; + ctp = csd_german; #endif - break; + break; - case 'Q': /* French Canadien */ + case 'Q': /* French Canadien */ #ifdef HAVECSD_FRENCHCANADA - ctp = csd_frenchcanada; + ctp = csd_frenchcanada; #endif - break; + break; - case 'R': /* French */ + case 'R': /* French */ #ifdef HAVECSD_FRENCH - ctp = csd_french; + ctp = csd_french; #endif - break; + break; - case 'X': /* KOI8 hack */ + case 'X': /* KOI8 hack */ #ifdef HAVECSD_KOI8 - ctp = csd_koi8; + ctp = csd_koi8; #endif - break; + break; - case 'Y': /* Italian */ + case 'Y': /* Italian */ #ifdef HAVECSD_ITALIAN - ctp = csd_italian; + ctp = csd_italian; #endif - break; + break; - case 'Z': /* Spanish */ + case 'Z': /* Spanish */ #ifdef HAVECSD_SPANISH - ctp = csd_spanish; + ctp = csd_spanish; #endif - break; + break; - case '0': /* special graphics */ + case '0': /* special graphics */ #ifdef HAVECSD_SPECIAL - ctp = csd_special; - pcdisp_special = 1; + ctp = csd_special; + pcdisp_special = 1; #endif - break; + break; - case '1': /* alternate ROM */ + case '1': /* alternate ROM */ #ifdef HAVECSD_ALTERNATEROM1 - ctp = csd_alternaterom1; + ctp = csd_alternaterom1; #endif - break; + break; - case '2': /* alt ROM, spec graphics */ + case '2': /* alt ROM, spec graphics */ #ifdef HAVECSD_ALTERNATEROM2 - ctp = csd_alternaterom2; + ctp = csd_alternaterom2; #endif - break; + break; - case '3': /* HP Roman 8, upper 128 chars*/ + case '3': /* HP Roman 8, upper 128 chars*/ #ifdef HAVECSD_ROMAN8 - ctp = csd_roman8; + ctp = csd_roman8; #endif - break; + break; - case '4': /* Dutch */ + case '4': /* Dutch */ #ifdef HAVECSD_DUTCH - ctp = csd_dutch; + ctp = csd_dutch; #endif - break; + break; - case '<': /* DEC Supplemental */ + case '<': /* DEC Supplemental */ #ifdef HAVECSD_SUPPLEMENTAL - ctp = csd_supplemental; - pcdisp_special = 1; + ctp = csd_supplemental; + pcdisp_special = 1; #endif - break; + break; - case '=': /* Swiss */ + case '=': /* Swiss */ #ifdef HAVECSD_SWISS - ctp = csd_swiss; + ctp = csd_swiss; #endif - break; + break; - case '>': /* DEC Technical */ + case '>': /* DEC Technical */ #ifdef HAVECSD_TECHNICAL - ctp = csd_technical; - pcdisp_special = 1; + ctp = csd_technical; + pcdisp_special = 1; #endif - break; + break; - default: - break; + default: + break; } } swcsp(svsp, ctp); @@ -1230,8 +1192,7 @@ vt_aln(struct video_state *svsp) svsp->cur_offset = 0; svsp->col = 0; - for(i=0; i < (svsp->screen_rows*svsp->maxcol); i++) - { + for (i = 0; i < (svsp->screen_rows*svsp->maxcol); i++) { *(svsp->Crtat + svsp->cur_offset) = user_attr | 'E'; vt_selattr(svsp); svsp->cur_offset++; @@ -1278,52 +1239,51 @@ vt_dsr(struct video_state *svsp) static u_char buffer[16]; int i = 0; - switch(svsp->parms[0]) - { - case 5: /* return status */ - svsp->report_chars = answr; - svsp->report_count = 4; - respond(svsp); - break; - - case 6: /* return cursor position */ - buffer[i++] = 0x1b; - buffer[i++] = '['; - if((svsp->row+1) > 10) - buffer[i++] = ((svsp->row+1) / 10) + '0'; - buffer[i++] = ((svsp->row+1) % 10) + '0'; - buffer[i++] = ';'; - if((svsp->col+1) > 10) - buffer[i++] = ((svsp->col+1) / 10) + '0'; - buffer[i++] = ((svsp->col+1) % 10) + '0'; - buffer[i++] = 'R'; - buffer[i++] = '\0'; - - svsp->report_chars = buffer; - svsp->report_count = i; - respond(svsp); - break; - - case 15: /* return printer status */ - svsp->report_chars = panswr; - svsp->report_count = 6; - respond(svsp); - break; - - case 25: /* return udk status */ - svsp->report_chars = udkanswr; - svsp->report_count = 6; - respond(svsp); - break; - - case 26: /* return language status */ - svsp->report_chars = langanswr; - svsp->report_count = 8; - respond(svsp); - break; - - default: /* nothing else valid */ - break; + switch (svsp->parms[0]) { + case 5: /* return status */ + svsp->report_chars = answr; + svsp->report_count = 4; + respond(svsp); + break; + + case 6: /* return cursor position */ + buffer[i++] = 0x1b; + buffer[i++] = '['; + if ((svsp->row+1) > 10) + buffer[i++] = ((svsp->row+1) / 10) + '0'; + buffer[i++] = ((svsp->row+1) % 10) + '0'; + buffer[i++] = ';'; + if ((svsp->col+1) > 10) + buffer[i++] = ((svsp->col+1) / 10) + '0'; + buffer[i++] = ((svsp->col+1) % 10) + '0'; + buffer[i++] = 'R'; + buffer[i++] = '\0'; + + svsp->report_chars = buffer; + svsp->report_count = i; + respond(svsp); + break; + + case 15: /* return printer status */ + svsp->report_chars = panswr; + svsp->report_count = 6; + respond(svsp); + break; + + case 25: /* return udk status */ + svsp->report_chars = udkanswr; + svsp->report_count = 6; + respond(svsp); + break; + + case 26: /* return language status */ + svsp->report_chars = langanswr; + svsp->report_count = 8; + respond(svsp); + break; + + default: /* nothing else valid */ + break; } } @@ -1335,26 +1295,25 @@ vt_il(struct video_state *svsp) { register int p = svsp->parms[0]; - if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end)) - { - if(p <= 0) + if ((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end)) { + if (p <= 0) p = 1; - else if(p > svsp->scrr_end - svsp->row) + else if (p > svsp->scrr_end - svsp->row) p = svsp->scrr_end - svsp->row; svsp->cur_offset -= svsp->col; svsp->col = 0; - if(svsp->row == svsp->scrr_beg) + if (svsp->row == svsp->scrr_beg) roll_down(svsp, p); - else - { - bcopy(svsp->Crtat + svsp->cur_offset, - svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol), - svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR ); - - fillw(user_attr | ' ', - (caddr_t)(svsp->Crtat + svsp->cur_offset), - p * svsp->maxcol); + else { + bcopy(svsp->Crtat + svsp->cur_offset, + svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol), + svsp->maxcol * (svsp->scrr_end-svsp->row + 1 - p) * + CHR); + + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + svsp->cur_offset), + p * svsp->maxcol); } } } @@ -1367,16 +1326,15 @@ vt_ic(struct video_state *svsp) { register int p = svsp->parms[0]; - if(p <= 0) + if (p <= 0) p = 1; - else if(p > svsp->maxcol-svsp->col) + else if (p > svsp->maxcol-svsp->col) p = svsp->maxcol-svsp->col; - while(p--) - { + while (p--) { bcopy((svsp->Crtat + svsp->cur_offset), - (svsp->Crtat + svsp->cur_offset) + 1, - (((svsp->maxcol)-1)-svsp->col) * CHR); + (svsp->Crtat + svsp->cur_offset) + 1, + (((svsp->maxcol)-1)-svsp->col) * CHR); *(svsp->Crtat + svsp->cur_offset) = user_attr | ' '; vt_selattr(svsp); @@ -1391,27 +1349,26 @@ vt_dl(struct video_state *svsp) { register int p = svsp->parms[0]; - if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end)) - { - if(p <= 0) + if ((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end)) { + if (p <= 0) p = 1; - else if(p > svsp->scrr_end - svsp->row) + else if (p > svsp->scrr_end - svsp->row) p = svsp->scrr_end - svsp->row; svsp->cur_offset -= svsp->col; svsp->col = 0; - if(svsp->row == svsp->scrr_beg) + if (svsp->row == svsp->scrr_beg) roll_up(svsp, p); - else - { - bcopy(svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol), - svsp->Crtat + svsp->cur_offset, - svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR ); - - fillw(user_attr | ' ',(caddr_t) - (svsp->Crtat + ((svsp->scrr_end-p+1) * svsp->maxcol)), - p * svsp->maxcol); + else { + bcopy(svsp->Crtat + svsp->cur_offset + (p * + svsp->maxcol), svsp->Crtat + svsp->cur_offset, + svsp->maxcol * (svsp->scrr_end-svsp->row + 1 - p) * + CHR); + + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + ((svsp->scrr_end-p+1) * + svsp->maxcol)), p * svsp->maxcol); } } } @@ -1424,19 +1381,18 @@ vt_dch(struct video_state *svsp) { register int p = svsp->parms[0]; - if(p <= 0) + if (p <= 0) p = 1; - else if(p > svsp->maxcol-svsp->col) + else if (p > svsp->maxcol-svsp->col) p = svsp->maxcol-svsp->col; - while(p--) - { - bcopy((svsp->Crtat + svsp->cur_offset)+1, - (svsp->Crtat + svsp->cur_offset), - (((svsp->maxcol)-1) - svsp->col)* CHR ); + while (p--) { + bcopy((svsp->Crtat + svsp->cur_offset) + 1, + (svsp->Crtat + svsp->cur_offset), + (((svsp->maxcol) - 1) - svsp->col) * CHR); *((svsp->Crtat + svsp->cur_offset) + - ((svsp->maxcol)-1)-svsp->col) = user_attr | ' '; + ((svsp->maxcol) - 1) - svsp->col) = user_attr | ' '; } } @@ -1448,10 +1404,10 @@ vt_su(struct video_state *svsp) { register int p = svsp->parms[0]; - if(p <= 0) + if (p <= 0) p = 1; - else if(p > svsp->screen_rows-1) - p = svsp->screen_rows-1; + else if (p > svsp->screen_rows - 1) + p = svsp->screen_rows - 1; roll_up(svsp, p); } @@ -1464,9 +1420,9 @@ vt_sd(struct video_state *svsp) { register int p = svsp->parms[0]; - if(p <= 0) + if (p <= 0) p = 1; - else if(p > svsp->screen_rows-1) + else if (p > svsp->screen_rows-1) p = svsp->screen_rows-1; roll_down(svsp, p); @@ -1480,10 +1436,10 @@ vt_ech(struct video_state *svsp) { register int p = svsp->parms[0]; - if(p <= 0) + if (p <= 0) p = 1; - else if(p > svsp->maxcol-svsp->col) - p = svsp->maxcol-svsp->col; + else if (p > svsp->maxcol-svsp->col) + p = svsp->maxcol - svsp->col; fillw(user_attr | ' ', (caddr_t)(svsp->Crtat + svsp->cur_offset), p); } @@ -1506,283 +1462,271 @@ vt_mc(struct video_state *svsp) void vt_dcsentry(U_char ch, struct video_state *svsp) { - switch(svsp->dcs_state) - { - case DCS_INIT: - switch(ch) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': /* parameters */ - svsp->parms[svsp->parmi] *= 10; - svsp->parms[svsp->parmi] += (ch -'0'); - break; - - case ';': /* next parameter */ - svsp->parmi = - (svsp->parmi+1 < MAXPARMS) ? - svsp->parmi+1 : svsp->parmi; - break; - - case '|': /* DECUDK */ - svsp->transparent = 1; - init_udk(svsp); - svsp->dcs_state = DCS_AND_UDK; - break; + switch (svsp->dcs_state) { + case DCS_INIT: + switch (ch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': /* parameters */ + svsp->parms[svsp->parmi] *= 10; + svsp->parms[svsp->parmi] += (ch -'0'); + break; + + case ';': /* next parameter */ + svsp->parmi = (svsp->parmi + 1 < MAXPARMS) ? + svsp->parmi + 1 : svsp->parmi; + break; + + case '|': /* DECUDK */ + svsp->transparent = 1; + init_udk(svsp); + svsp->dcs_state = DCS_AND_UDK; + break; - case '{': /* DECDLD */ - svsp->transparent = 1; - init_dld(svsp); - svsp->dcs_state = DCS_DLD_DSCS; - break; + case '{': /* DECDLD */ + svsp->transparent = 1; + init_dld(svsp); + svsp->dcs_state = DCS_DLD_DSCS; + break; - default: /* failsafe */ - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; - break; - } + default: /* failsafe */ + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; break; + } + break; - case DCS_AND_UDK: /* DCS ... | */ - switch(ch) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': /* fkey number */ - svsp->udk_fnckey *= 10; - svsp->udk_fnckey += (ch -'0'); - break; + case DCS_AND_UDK: /* DCS ... | */ + switch (ch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': /* fkey number */ + svsp->udk_fnckey *= 10; + svsp->udk_fnckey += (ch -'0'); + break; - case '/': /* Key */ - svsp->dcs_state = DCS_UDK_DEF; - break; + case '/': /* Key */ + svsp->dcs_state = DCS_UDK_DEF; + break; - case 0x1b: /* ESC */ - svsp->dcs_state = DCS_UDK_ESC; - break; + case 0x1b: /* ESC */ + svsp->dcs_state = DCS_UDK_ESC; + break; - default: - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; - break; + default: + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; + break; + } + break; + + case DCS_UDK_DEF: /* DCS ... | fnckey / */ + switch (ch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (svsp->udk_deflow) { /* low nibble */ + svsp->udk_def[svsp->udk_defi] |= (ch - '0'); + svsp->udk_deflow = 0; + svsp->udk_defi = (svsp->udk_defi + 1 >= + MAXUDKDEF) ? svsp->udk_defi : + svsp->udk_defi + 1; + } + else { /* high nibble */ + svsp->udk_def[svsp->udk_defi] = + ((ch - '0') << 4); + svsp->udk_deflow = 1; } break; - case DCS_UDK_DEF: /* DCS ... | fnckey / */ - switch(ch) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if(svsp->udk_deflow) /* low nibble */ - { - svsp->udk_def[svsp->udk_defi] |= (ch -'0'); - svsp->udk_deflow = 0; - svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ? - svsp->udk_defi : svsp->udk_defi+1; - } - else /* high nibble */ - { - svsp->udk_def[svsp->udk_defi] = ((ch -'0') << 4); - svsp->udk_deflow = 1; - } - break; - - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - if(svsp->udk_deflow) /* low nibble */ - { - svsp->udk_def[svsp->udk_defi] |= (ch - 'a' + 10); - svsp->udk_deflow = 0; - svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ? - svsp->udk_defi : svsp->udk_defi+1; - } - else /* high nibble */ - { - svsp->udk_def[svsp->udk_defi] = ((ch - 'a' + 10) << 4); - svsp->udk_deflow = 1; - } - break; - - + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + if (svsp->udk_deflow) { /* low nibble */ + svsp->udk_def[svsp->udk_defi] |= + (ch - 'a' + 10); + svsp->udk_deflow = 0; + svsp->udk_defi = (svsp->udk_defi + 1 >= + MAXUDKDEF) ? svsp->udk_defi : + svsp->udk_defi + 1; + } + else { /* high nibble */ + svsp->udk_def[svsp->udk_defi] = + ((ch - 'a' + 10) << 4); + svsp->udk_deflow = 1; + } + break; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - if(svsp->udk_deflow) /* low nibble */ - { - svsp->udk_def[svsp->udk_defi] |= (ch - 'A' + 10); - svsp->udk_deflow = 0; - svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ? - svsp->udk_defi : svsp->udk_defi+1; - } - else /* high nibble */ - { - svsp->udk_def[svsp->udk_defi] = ((ch - 'A' + 10) << 4); - svsp->udk_deflow = 1; - } - break; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + if (svsp->udk_deflow) { /* low nibble */ + svsp->udk_def[svsp->udk_defi] |= + (ch - 'A' + 10); + svsp->udk_deflow = 0; + svsp->udk_defi = (svsp->udk_defi+1 >= + MAXUDKDEF) ? svsp->udk_defi : + svsp->udk_defi + 1; + } + else { /* high nibble */ + svsp->udk_def[svsp->udk_defi] = + ((ch - 'A' + 10) << 4); + svsp->udk_deflow = 1; + } + break; - case ';': /* next function key */ - vt_udk(svsp); - svsp->dcs_state = DCS_AND_UDK; - break; + case ';': /* next function key */ + vt_udk(svsp); + svsp->dcs_state = DCS_AND_UDK; + break; - case 0x1b: /* ESC */ - svsp->dcs_state = DCS_UDK_ESC; - break; + case 0x1b: /* ESC */ + svsp->dcs_state = DCS_UDK_ESC; + break; - default: - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; - break; - } + default: + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; break; + } + break; - case DCS_UDK_ESC: /* DCS ... | fkey/def ... ESC */ - switch(ch) - { - case '\\': /* ST */ - vt_udk(svsp); - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; - break; + case DCS_UDK_ESC: /* DCS ... | fkey/def ... ESC */ + switch (ch) { + case '\\': /* ST */ + vt_udk(svsp); + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; + break; - default: - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; - break; - } + default: + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; break; + } + break; - case DCS_DLD_DSCS: /* got DCS ... { */ - if(ch >= ' ' && ch <= '/') /* intermediates ... */ - { - svsp->dld_dscs[svsp->dld_dscsi] = ch; - svsp->dld_id[svsp->dld_dscsi] = ch; - if(svsp->dld_dscsi >= DSCS_LENGTH) - { - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; - svsp->dld_id[0] = '\0'; - } - else - { - svsp->dld_dscsi++; - } - } - else if(ch >= '0' && ch <= '~') /* final .... */ - { - svsp->dld_dscs[svsp->dld_dscsi] = ch; - svsp->dld_id[svsp->dld_dscsi++] = ch; - svsp->dld_id[svsp->dld_dscsi] = '\0'; - svsp->dcs_state = DCS_DLD_DEF; - } - else - { + case DCS_DLD_DSCS: /* got DCS ... { */ + if (ch >= ' ' && ch <= '/') { /* intermediates ... */ + svsp->dld_dscs[svsp->dld_dscsi] = ch; + svsp->dld_id[svsp->dld_dscsi] = ch; + if (svsp->dld_dscsi >= DSCS_LENGTH) { svsp->transparent = 0; svsp->state = STATE_INIT; svsp->dcs_state = DCS_INIT; svsp->dld_id[0] = '\0'; } - break; - - case DCS_DLD_DEF: /* DCS ... { dscs */ - switch(ch) - { - case 0x1b: /* ESC */ - svsp->dcs_state = DCS_DLD_ESC; - break; + else + svsp->dld_dscsi++; + } + else if (ch >= '0' && ch <= '~') { /* final .... */ + svsp->dld_dscs[svsp->dld_dscsi] = ch; + svsp->dld_id[svsp->dld_dscsi++] = ch; + svsp->dld_id[svsp->dld_dscsi] = '\0'; + svsp->dcs_state = DCS_DLD_DEF; + } + else { + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; + svsp->dld_id[0] = '\0'; + } + break; - case '/': /* sixel upper / lower divider */ - svsp->dld_sixel_lower = 1; - break; + case DCS_DLD_DEF: /* DCS ... { dscs */ + switch (ch) { + case 0x1b: /* ESC */ + svsp->dcs_state = DCS_DLD_ESC; + break; - case ';': /* character divider */ - vt_dld(svsp); - svsp->parms[1]++; /* next char */ - break; + case '/': /* sixel upper / lower divider */ + svsp->dld_sixel_lower = 1; + break; - default: - if (svsp->dld_sixel_lower) - { - if(ch >= '?' && ch <= '~') - svsp->sixel.lower[svsp->dld_sixelli] = ch - '?'; - svsp->dld_sixelli = - (svsp->dld_sixelli+1 < MAXSIXEL) ? - svsp->dld_sixelli+1 : svsp->dld_sixelli; - } - else - { - if(ch >= '?' && ch <= '~') - svsp->sixel.upper[svsp->dld_sixelui] = ch - '?'; - svsp->dld_sixelui = - (svsp->dld_sixelui+1 < MAXSIXEL) ? - svsp->dld_sixelui+1 : svsp->dld_sixelui; - } - break; - } + case ';': /* character divider */ + vt_dld(svsp); + svsp->parms[1]++; /* next char */ break; - case DCS_DLD_ESC: /* DCS ... { dscs ... / ... ESC */ - switch(ch) - { - case '\\': /* String Terminator ST */ - vt_dld(svsp); - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; + default: + if (svsp->dld_sixel_lower) { + if (ch >= '?' && ch <= '~') { + svsp->sixel.lower[svsp->dld_sixelli] = + ch - '?'; + } + svsp->dld_sixelli = + (svsp->dld_sixelli + 1 < MAXSIXEL) ? + svsp->dld_sixelli + 1 : svsp->dld_sixelli; + } + else { + if (ch >= '?' && ch <= '~') { + svsp->sixel.upper[svsp->dld_sixelui] = + ch - '?'; + } + svsp->dld_sixelui = + (svsp->dld_sixelui + 1 < MAXSIXEL) ? + svsp->dld_sixelui+1 : svsp->dld_sixelui; + } break; + } + break; - default: - svsp->transparent = 0; - svsp->state = STATE_INIT; - svsp->dcs_state = DCS_INIT; - svsp->dld_id[0] = '\0'; - break; - } + case DCS_DLD_ESC: /* DCS ... { dscs ... / ... ESC */ + switch (ch) { + case '\\': /* String Terminator ST */ + vt_dld(svsp); + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; break; default: svsp->transparent = 0; svsp->state = STATE_INIT; svsp->dcs_state = DCS_INIT; + svsp->dld_id[0] = '\0'; break; + } + break; + + default: + svsp->transparent = 0; + svsp->state = STATE_INIT; + svsp->dcs_state = DCS_INIT; + break; } } @@ -1795,56 +1739,49 @@ vt_udk(struct video_state *svsp) int key, start, max, i; int usedff = 0; - if(svsp->parms[0] != 1) /* clear all ? */ - { + if (svsp->parms[0] != 1) { /* clear all ? */ vt_clearudk(svsp); svsp->parms[0] = 1; } - if(svsp->udk_fnckey < 17 || svsp->udk_fnckey > 34) - { + if (svsp->udk_fnckey < 17 || svsp->udk_fnckey > 34) { init_udk(svsp); return; } key = svsp->udk_fnckey - 17; /* index into table */ - if(svsp->ukt.length[key] == 0) /* never used ? */ - { - if(svsp->udkff < MAXUDKDEF-2) /* space available ? */ - { + if (svsp->ukt.length[key] == 0) { /* never used ? */ + if (svsp->udkff < MAXUDKDEF - 2) { /* space available ? */ start = svsp->udkff; /* next sequential */ max = MAXUDKDEF - svsp->udkff; /* space available */ svsp->ukt.first[key] = start; /* start entry */ usedff = 1; /* flag to update later */ } - else /* no space */ - { + else { /* no space */ init_udk(svsp); return; } } - else /* in use, redefine */ - { + else { /* in use, redefine */ start = svsp->ukt.first[key]; /* start entry */ max = svsp->ukt.length[key]; /* space available */ } - if(max < 2) /* hmmm .. */ - { + if (max < 2) { /* hmmm .. */ init_udk(svsp); return; } max--; /* adjust for tailing '\0' */ - for(i = 0; i < max && i < svsp->udk_defi; i++) + for (i = 0; i < max && i < svsp->udk_defi; i++) svsp->udkbuf[start++] = svsp->udk_def[i]; svsp->udkbuf[start] = '\0'; /* make it a string, see pcvt_kbd.c */ - svsp->ukt.length[key] = i+1; /* count for tailing '\0' */ - if(usedff) - svsp->udkff += (i+2); /* new start location */ + svsp->ukt.length[key] = i + 1; /* count for tailing '\0' */ + if (usedff) + svsp->udkff += (i + 2); /* new start location */ init_udk(svsp); } @@ -1857,8 +1794,7 @@ vt_clearudk(struct video_state *svsp) { register int i; - for(i = 0; i < MAXUDKEYS; i++) - { + for (i = 0; i < MAXUDKEYS; i++) { svsp->ukt.first[i] = 0; svsp->ukt.length[i] = 0; } @@ -1875,40 +1811,38 @@ vt_dld(struct video_state *svsp) unsigned char vgachar[16]; unsigned char vgacharb[16]; - if(vgacs[svsp->vga_charset].secondloaded) + if (vgacs[svsp->vga_charset].secondloaded) vgacharset = vgacs[svsp->vga_charset].secondloaded; else return; svsp->parms[1] = (svsp->parms[1] < 1) ? 1 : - ((svsp->parms[1] > 0x7E) ? 0x7E : svsp->parms[1]); + ((svsp->parms[1] > 0x7E) ? 0x7E : svsp->parms[1]); - if(svsp->parms[2] != 1) /* Erase all characters ? */ - { + if (svsp->parms[2] != 1) { /* Erase all characters ? */ clear_dld(svsp); - svsp->parms[2] = 1; /* Only erase all characters once per sequence */ + svsp->parms[2] = 1; /* Only erase all characters once per sequence */ } - sixel_vga(&(svsp->sixel),vgachar); + sixel_vga(&(svsp->sixel), vgachar); - switch(vgacs[vgacharset].char_scanlines & 0x1F) - { - case 7: - vga10_vga8(vgachar,vgacharb); - break; + switch (vgacs[vgacharset].char_scanlines & 0x1F) { + case 7: + vga10_vga8(vgachar, vgacharb); + break; - case 9: - default: - vga10_vga10(vgachar,vgacharb); - break; + case 13: + vga10_vga14(vgachar, vgacharb); + break; - case 13: - vga10_vga14(vgachar,vgacharb); - break; + case 15: + vga10_vga16(vgachar, vgacharb); + break; - case 15: - vga10_vga16(vgachar,vgacharb); - break; + case 9: + default: + vga10_vga10(vgachar, vgacharb); + break; } loadchar(vgacharset, svsp->parms[1] + 0xA0, 16, vgacharb); @@ -1934,17 +1868,16 @@ vt_scl(struct video_state *svsp) vt_str(svsp); - switch(p0) - { - case 61: - svsp->sevenbit = 1; - break; - case 62: - /* case 63: vt320 */ - default: - if(p1 != 1) - svsp->C1_ctls = 1; - break; + switch (p0) { + case 61: + svsp->sevenbit = 1; + break; + case 62: + /* case 63: vt320 */ + default: + if (p1 != 1) + svsp->C1_ctls = 1; + break; } } @@ -1954,16 +1887,15 @@ vt_scl(struct video_state *svsp) void vt_sca(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 1: - svsp->selchar = 1; - break; - case 0: - case 2: - default: - svsp->selchar = 0; - break; + switch (svsp->parms[0]) { + case 1: + svsp->selchar = 1; + break; + case 0: + case 2: + default: + svsp->selchar = 0; + break; } } @@ -1975,7 +1907,7 @@ vt_initsel(struct video_state *svsp) { register int i; - for(i = 0;i < MAXDECSCA;i++) + for (i = 0; i < MAXDECSCA; i++) svsp->decsca[i] = 0; } @@ -1985,22 +1917,21 @@ vt_initsel(struct video_state *svsp) void vt_sel(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: - selective_erase(svsp, (svsp->Crtat + svsp->cur_offset), - svsp->maxcol-svsp->col); - break; - - case 1: - selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)- - svsp->col, svsp->col + 1); - break; - - case 2: - selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)- - svsp->col, svsp->maxcol); - break; + switch (svsp->parms[0]) { + case 0: + selective_erase(svsp, (svsp->Crtat + svsp->cur_offset), + svsp->maxcol-svsp->col); + break; + + case 1: + selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)- + svsp->col, svsp->col + 1); + break; + + case 2: + selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)- + svsp->col, svsp->maxcol); + break; } } @@ -2010,23 +1941,22 @@ vt_sel(struct video_state *svsp) void vt_sed(struct video_state *svsp) { - switch(svsp->parms[0]) - { - case 0: - selective_erase(svsp, (svsp->Crtat + svsp->cur_offset), - svsp->Crtat + (svsp->maxcol * svsp->screen_rows) - - (svsp->Crtat + svsp->cur_offset)); - break; - - case 1: - selective_erase(svsp, svsp->Crtat, - (svsp->Crtat + svsp->cur_offset) - svsp->Crtat + 1 ); - break; - - case 2: - selective_erase(svsp, svsp->Crtat, - svsp->maxcol * svsp->screen_rows); - break; + switch (svsp->parms[0]) { + case 0: + selective_erase(svsp, (svsp->Crtat + svsp->cur_offset), + svsp->Crtat + (svsp->maxcol * svsp->screen_rows) - + (svsp->Crtat + svsp->cur_offset)); + break; + + case 1: + selective_erase(svsp, svsp->Crtat, + (svsp->Crtat + svsp->cur_offset) - svsp->Crtat + 1); + break; + + case 2: + selective_erase(svsp, svsp->Crtat, + svsp->maxcol * svsp->screen_rows); + break; } } @@ -2039,7 +1969,7 @@ roll_up(struct video_state *svsp, int n) #if (PCVT_NOFASTSCROLL==0) - if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */ + if (svsp->scrr_beg == 0 && /* if scroll region is whole screen */ svsp->scrr_len == svsp->screen_rows && (svsp != vsp || /* and either running in memory */ (svsp->screen_rows == svsp->screen_rowsize /* or no fkeys */ @@ -2055,32 +1985,29 @@ roll_up(struct video_state *svsp, int n) (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ? svsp->Memory : Crtat; - if(svsp->Crtat > (Memory + (svsp->screen_rows - n) * - svsp->maxcol)) - { + if (svsp->Crtat > (Memory + (svsp->screen_rows - n) * + svsp->maxcol)) { bcopy(svsp->Crtat + svsp->maxcol * n, Memory, svsp->maxcol * (svsp->screen_rows - n) * CHR); svsp->Crtat = Memory; } else - { svsp->Crtat += n * svsp->maxcol; - } } else #endif { - bcopy( svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol), - svsp->Crtat + (svsp->scrr_beg * svsp->maxcol), - svsp->maxcol * (svsp->scrr_len - n) * CHR ); + bcopy(svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol), + svsp->Crtat + (svsp->scrr_beg * svsp->maxcol), + svsp->maxcol * (svsp->scrr_len - n) * CHR ); } - fillw( user_attr | ' ',(caddr_t) - (svsp->Crtat + ((svsp->scrr_end - n + 1) * svsp->maxcol)), - n * svsp->maxcol); + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + ((svsp->scrr_end - n + 1) * svsp->maxcol)), + n * svsp->maxcol); -/*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc) +/*XXX*/ if (svsp->scroll_lock && svsp->openf && curproc) tsleep((caddr_t)&(svsp->scroll_lock), PUSER, "scrlck", 0); } @@ -2093,7 +2020,7 @@ roll_down(struct video_state *svsp, int n) #if (PCVT_NOFASTSCROLL==0) - if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */ + if (svsp->scrr_beg == 0 && /* if scroll region is whole screen */ svsp->scrr_len == svsp->screen_rows && (svsp != vsp || /* and either running in memory */ (svsp->screen_rows == svsp->screen_rowsize /* or no fkeys */ @@ -2109,32 +2036,29 @@ roll_down(struct video_state *svsp, int n) (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ? svsp->Memory : Crtat; - if (svsp->Crtat < (Memory + n * svsp->maxcol)) - { + if (svsp->Crtat < (Memory + n * svsp->maxcol)) { bcopy(svsp->Crtat, - Memory + svsp->maxcol * (svsp->screen_rows + n), - svsp->maxcol * (svsp->screen_rows - n) * CHR); + Memory + svsp->maxcol * (svsp->screen_rows + n), + svsp->maxcol * (svsp->screen_rows - n) * CHR); svsp->Crtat = Memory + svsp->maxcol * svsp->screen_rows; } else - { svsp->Crtat -= n * svsp->maxcol; - } } else #endif { - bcopy( svsp->Crtat + (svsp->scrr_beg * svsp->maxcol), - svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol), - svsp->maxcol * (svsp->scrr_len - n) * CHR ); + bcopy(svsp->Crtat + (svsp->scrr_beg * svsp->maxcol), + svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol), + svsp->maxcol * (svsp->scrr_len - n) * CHR); } - fillw( user_attr | ' ',(caddr_t) - (svsp->Crtat + (svsp->scrr_beg * svsp->maxcol)), - n * svsp->maxcol); + fillw(user_attr | ' ', + (caddr_t)(svsp->Crtat + (svsp->scrr_beg * svsp->maxcol)), + n * svsp->maxcol); -/*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc) +/*XXX*/ if (svsp->scroll_lock && svsp->openf && curproc) tsleep((caddr_t)&(svsp->scroll_lock), PUSER, "scrlck", 0); } @@ -2144,47 +2068,46 @@ roll_down(struct video_state *svsp, int n) static void swcsp(struct video_state *svsp, u_short *ctp) { - if(ctp == NULL) + if (ctp == NULL) return; /* update GL or GR if the designated charset is currently displayed */ - switch(svsp->state) - { - case STATE_BROPN: /* designate G0 */ - if (svsp->GL == svsp->G0) - svsp->GL = ctp; - if (svsp->GR == svsp->G0) - svsp->GR = ctp; - svsp->G0 = ctp; - break; - - case STATE_BRCLO: /* designate G1 */ - case STATE_MINUS: /* designate G1 (96) */ - if (svsp->GL == svsp->G1) - svsp->GL = ctp; - if (svsp->GR == svsp->G1) - svsp->GR = ctp; - svsp->G1 = ctp; - break; - - case STATE_STAR: /* designate G2 */ - case STATE_DOT: /* designate G2 (96) */ - if (svsp->GL == svsp->G2) - svsp->GL = ctp; - if (svsp->GR == svsp->G2) - svsp->GR = ctp; - svsp->G2 = ctp; - break; - - case STATE_PLUS: /* designate G3 */ - case STATE_SLASH: /* designate G3 (96) */ - if (svsp->GL == svsp->G3) - svsp->GL = ctp; - if (svsp->GR == svsp->G3) - svsp->GR = ctp; - svsp->G3 = ctp; - break; + switch (svsp->state) { + case STATE_BROPN: /* designate G0 */ + if (svsp->GL == svsp->G0) + svsp->GL = ctp; + if (svsp->GR == svsp->G0) + svsp->GR = ctp; + svsp->G0 = ctp; + break; + + case STATE_BRCLO: /* designate G1 */ + case STATE_MINUS: /* designate G1 (96) */ + if (svsp->GL == svsp->G1) + svsp->GL = ctp; + if (svsp->GR == svsp->G1) + svsp->GR = ctp; + svsp->G1 = ctp; + break; + + case STATE_STAR: /* designate G2 */ + case STATE_DOT: /* designate G2 (96) */ + if (svsp->GL == svsp->G2) + svsp->GL = ctp; + if (svsp->GR == svsp->G2) + svsp->GR = ctp; + svsp->G2 = ctp; + break; + + case STATE_PLUS: /* designate G3 */ + case STATE_SLASH: /* designate G3 (96) */ + if (svsp->GL == svsp->G3) + svsp->GL = ctp; + if (svsp->GR == svsp->G3) + svsp->GR = ctp; + svsp->G3 = ctp; + break; } } @@ -2194,13 +2117,12 @@ swcsp(struct video_state *svsp, u_short *ctp) static void respond(struct video_state *svsp) { - if(!(svsp->openf)) /* are we opened ? */ + if (!(svsp->openf)) /* are we opened ? */ return; - while (*svsp->report_chars && svsp->report_count > 0) - { + while (*svsp->report_chars && svsp->report_count > 0) { (*linesw[svsp->vs_tty->t_line].l_rint) - (*svsp->report_chars++ & 0xff, svsp->vs_tty); + (*svsp->report_chars++ & 0xff, svsp->vs_tty); svsp->report_count--; } } @@ -2226,15 +2148,15 @@ clear_dld(struct video_state *svsp) unsigned char vgacharset; unsigned char vgachar[16]; - if(vgacs[svsp->vga_charset].secondloaded) + if (vgacs[svsp->vga_charset].secondloaded) vgacharset = vgacs[svsp->vga_charset].secondloaded; else return; - for(i=0;i < 16;i++) /* A zeroed character, vt220 has inverted '?' */ + for (i = 0; i < 16; i++) /* zeroed character, vt220 has inverted '?' */ vgachar[i] = 0x00; - for(i=1;i <= 94;i++) /* Load (erase) all characters */ + for (i = 1; i <= 94; i++) /* Load (erase) all characters */ loadchar(vgacharset, i + 0xA0, 16, vgachar); } @@ -2251,7 +2173,7 @@ init_dld(struct video_state *svsp) svsp->dld_sixelli = 0; svsp->dld_sixelui = 0; - for(i = 0;i < MAXSIXEL;i++) + for (i = 0; i < MAXSIXEL; i++) svsp->sixel.lower[i] = svsp->sixel.upper[i] = 0; } @@ -2263,11 +2185,9 @@ selective_erase(struct video_state *svsp, u_short *pcrtat, int length) { register int i, j; - for(j = pcrtat - svsp->Crtat, i = 0;i < length;i++,pcrtat++) - { - if(!(svsp->decsca[INT_INDEX(j+i)] & (1 << BIT_INDEX(j+i)))) - { - *pcrtat &= 0xFF00; /* Keep the video character attributes */ + for (j = pcrtat - svsp->Crtat, i = 0; i < length; i++, pcrtat++) { + if (!(svsp->decsca[INT_INDEX(j+i)] & (1 << BIT_INDEX(j+i)))) { + *pcrtat &= 0xFF00; /* Keep video character attributes */ *pcrtat += ' '; /* Erase the character */ } } |