mirror of https://github.com/FDOS/kernel.git
Clean up scr_pos updating routines: combine into update_scr_pos() function
instead of 2 copies of the same thing. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@760 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
b7491eba32
commit
d4f6a7104b
|
@ -196,14 +196,9 @@ STATIC void fast_put_char(unsigned char chr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* writes a character in cooked mode; maybe with printer echo;
|
void update_scr_pos(unsigned char c, unsigned char count)
|
||||||
handles TAB expansion */
|
|
||||||
STATIC int cooked_write_char(struct dhdr FAR **pdev,
|
|
||||||
unsigned char c,
|
|
||||||
unsigned char *fast_counter)
|
|
||||||
{
|
{
|
||||||
unsigned char scrpos = scr_pos;
|
unsigned char scrpos = scr_pos;
|
||||||
unsigned char count = 1;
|
|
||||||
|
|
||||||
if (c == CR)
|
if (c == CR)
|
||||||
scrpos = 0;
|
scrpos = 0;
|
||||||
|
@ -211,13 +206,24 @@ STATIC int cooked_write_char(struct dhdr FAR **pdev,
|
||||||
if (scrpos > 0)
|
if (scrpos > 0)
|
||||||
scrpos--;
|
scrpos--;
|
||||||
} else if (c != LF && c != BELL) {
|
} else if (c != LF && c != BELL) {
|
||||||
if (c == HT) {
|
|
||||||
count = 8 - (scrpos & 7);
|
|
||||||
c = ' ';
|
|
||||||
}
|
|
||||||
scrpos += count;
|
scrpos += count;
|
||||||
}
|
}
|
||||||
scr_pos = scrpos;
|
scr_pos = scrpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* writes a character in cooked mode; maybe with printer echo;
|
||||||
|
handles TAB expansion */
|
||||||
|
STATIC int cooked_write_char(struct dhdr FAR **pdev,
|
||||||
|
unsigned char c,
|
||||||
|
unsigned char *fast_counter)
|
||||||
|
{
|
||||||
|
unsigned char count = 1;
|
||||||
|
|
||||||
|
if (c == HT) {
|
||||||
|
count = 8 - (scr_pos & 7);
|
||||||
|
c = ' ';
|
||||||
|
}
|
||||||
|
update_scr_pos(c, count);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
@ -277,28 +283,19 @@ void write_char(int c, int sft_idx)
|
||||||
|
|
||||||
void write_char_stdout(int c)
|
void write_char_stdout(int c)
|
||||||
{
|
{
|
||||||
unsigned char scrpos = scr_pos;
|
|
||||||
unsigned char count = 1;
|
unsigned char count = 1;
|
||||||
unsigned flags = get_sft(STDOUT)->sft_flags & (SFT_FDEVICE | SFT_FBINARY);
|
unsigned flags = get_sft(STDOUT)->sft_flags & (SFT_FDEVICE | SFT_FBINARY);
|
||||||
|
|
||||||
/* ah=2, ah=9 should expand tabs even for raw devices and disk files */
|
/* ah=2, ah=9 should expand tabs even for raw devices and disk files */
|
||||||
if (flags != SFT_FDEVICE)
|
if (flags != SFT_FDEVICE)
|
||||||
{
|
{
|
||||||
if (c == CR)
|
|
||||||
scrpos = 0;
|
|
||||||
else if (c == BS) {
|
|
||||||
if (scrpos > 0)
|
|
||||||
scrpos--;
|
|
||||||
} else if (c != LF && c != BELL) {
|
|
||||||
if (c == HT) {
|
if (c == HT) {
|
||||||
count = 8 - (scrpos & 7);
|
count = 8 - (scr_pos & 7);
|
||||||
c = ' ';
|
c = ' ';
|
||||||
}
|
}
|
||||||
scrpos += count;
|
|
||||||
}
|
|
||||||
/* for raw devices already updated in dosfns.c */
|
/* for raw devices already updated in dosfns.c */
|
||||||
if (!(flags & SFT_FDEVICE))
|
if (!(flags & SFT_FDEVICE))
|
||||||
scr_pos = scrpos;
|
update_scr_pos(c, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -247,25 +247,8 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
|
||||||
{
|
{
|
||||||
size_t cnt = (size_t)rc;
|
size_t cnt = (size_t)rc;
|
||||||
const char FAR *p = bp;
|
const char FAR *p = bp;
|
||||||
unsigned char scrpos = scr_pos;
|
|
||||||
while (cnt--)
|
while (cnt--)
|
||||||
{
|
update_scr_pos(*p++, 1);
|
||||||
switch (*p++)
|
|
||||||
{
|
|
||||||
case CR:
|
|
||||||
scrpos = 0;
|
|
||||||
break;
|
|
||||||
case LF:
|
|
||||||
case BELL:
|
|
||||||
break;
|
|
||||||
case BS:
|
|
||||||
--scrpos;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
++scrpos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scr_pos = scrpos;
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp);
|
||||||
size_t read_line_handle(int sft_idx, size_t n, char FAR * bp);
|
size_t read_line_handle(int sft_idx, size_t n, char FAR * bp);
|
||||||
void write_char(int c, int sft_idx);
|
void write_char(int c, int sft_idx);
|
||||||
void write_char_stdout(int c);
|
void write_char_stdout(int c);
|
||||||
|
void update_scr_pos(unsigned char c, unsigned char count);
|
||||||
long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp);
|
long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp);
|
||||||
|
|
||||||
sft FAR *get_sft(UCOUNT);
|
sft FAR *get_sft(UCOUNT);
|
||||||
|
|
Loading…
Reference in New Issue