Added ANSI Erase in Line
This commit is contained in:
parent
a14406b6de
commit
b0c4e1ef36
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -54,3 +54,5 @@ samples/HelloPGX/hello.pgx
|
|||
samples/HelloPGX/hello.pgx
|
||||
samples/HelloPGX/hello.lst
|
||||
src/mapfile
|
||||
src/mapfile
|
||||
src/mapfile
|
||||
|
|
|
@ -50,6 +50,7 @@ extern void ansi_cub(p_channel chan, short arg_count, short args[]);
|
|||
extern void ansi_cud(p_channel chan, short arg_count, short args[]);
|
||||
extern void ansi_cup(p_channel chan, short arg_count, short args[]);
|
||||
extern void ansi_ed(p_channel chan, short arg_count, short args[]);
|
||||
extern void ansi_el(p_channel chan, short arg_count, short args[]);
|
||||
|
||||
/*
|
||||
* Console variables and constants
|
||||
|
@ -67,6 +68,7 @@ const t_ansi_seq ansi_sequence[] = {
|
|||
{ "\x1B[#C", ansi_cub },
|
||||
{ "\x1B[#D", ansi_cud },
|
||||
{ "\x1B[#J", ansi_ed },
|
||||
{ "\x1B[#K", ansi_el },
|
||||
{ "\x1B[#;#H", ansi_cup },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
@ -188,6 +190,21 @@ void ansi_ed(p_channel chan, short arg_count, short args[]) {
|
|||
text_clear(chan->dev, n);
|
||||
}
|
||||
|
||||
/*
|
||||
* ANSI Handler: erase in line
|
||||
*/
|
||||
void ansi_el(p_channel chan, short arg_count, short args[]) {
|
||||
unsigned short n = 2;
|
||||
|
||||
TRACE("ansi_el");
|
||||
|
||||
if (arg_count > 0) {
|
||||
n = args[0];
|
||||
}
|
||||
|
||||
text_clear_line(chan->dev, n);
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the console... nothing needs to happen here
|
||||
//
|
||||
|
|
|
@ -307,25 +307,30 @@ void text_set_color(short screen, short foreground, short background) {
|
|||
*
|
||||
* Inputs:
|
||||
* screen = the screen number 0 for channel A, 1 for channel B
|
||||
* mode = 0: erase from home to cursor, 1: erase from cursor to end of screen, 2: erase entire screen
|
||||
* mode = 0: erase from the cursor to the end of the screen,
|
||||
1: erase from start of the screen to the cursor,
|
||||
2: erase entire screen
|
||||
*/
|
||||
void text_clear(short screen, short mode) {
|
||||
if (screen < MAX_TEXT_CHANNELS) {
|
||||
int i;
|
||||
int sos_index = 0;
|
||||
p_text_channel chan = &text_channel[screen];
|
||||
int eos_index = chan->columns_max * chan->rows_max;
|
||||
int cursor_index = chan->y * chan->columns_max + chan->x;
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
/* Clear from cursor to the end of the screen */
|
||||
for (i = chan->y * chan->columns_max + chan->x; i < chan->columns_max * chan->rows_max; i++) {
|
||||
for (i = cursor_index; i < eos_index; i++) {
|
||||
chan->text_cells[i] = ' ';
|
||||
chan->color_cells[i] = chan->current_color;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
/* Clear from (0, 0) to cursor */
|
||||
for (i = 0; i <= chan->y * chan->columns_max + chan->x; i++) {
|
||||
for (i = sos_index; i <= cursor_index; i++) {
|
||||
chan->text_cells[i] = ' ';
|
||||
chan->color_cells[i] = chan->current_color;
|
||||
}
|
||||
|
@ -333,7 +338,55 @@ void text_clear(short screen, short mode) {
|
|||
|
||||
case 2:
|
||||
/* Clear entire screen */
|
||||
for (i = 0; i < chan->columns_max * chan->rows_max; i++) {
|
||||
for (i = sos_index; i <= eos_index; i++) {
|
||||
chan->text_cells[i] = ' ';
|
||||
chan->color_cells[i] = chan->current_color;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear part or all of the current line
|
||||
*
|
||||
* Inputs:
|
||||
* screen = the screen number 0 for channel A, 1 for channel B
|
||||
* mode = 0: erase from the cursor to the end of the line
|
||||
* 1: erase from the start of the line to the cursor
|
||||
* 2: erase entire line
|
||||
*/
|
||||
void text_clear_line(short screen, short mode) {
|
||||
if (screen < MAX_TEXT_CHANNELS) {
|
||||
int i;
|
||||
p_text_channel chan = &text_channel[screen];
|
||||
int sol_index = chan->y * chan->columns_max;
|
||||
int eol_index = (chan->y + 1) * chan->columns_max;
|
||||
int cursor_index = chan->y * chan->columns_max + chan->x;
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
/* Clear from cursor to the end of the line */
|
||||
for (i = cursor_index; i < eol_index; i++) {
|
||||
chan->text_cells[i] = ' ';
|
||||
chan->color_cells[i] = chan->current_color;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* Clear from (0, y) to cursor */
|
||||
for (i = sol_index; i <= cursor_index; i++) {
|
||||
chan->text_cells[i] = ' ';
|
||||
chan->color_cells[i] = chan->current_color;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* Clear entire screen */
|
||||
for (i = sol_index; i < eol_index; i++) {
|
||||
chan->text_cells[i] = ' ';
|
||||
chan->color_cells[i] = chan->current_color;
|
||||
}
|
||||
|
@ -415,16 +468,3 @@ void text_put_raw(short screen, char c) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a character to the screen... but handle ANSI escape codes and process accordingly.
|
||||
*
|
||||
* Inputs:
|
||||
* screen = the screen number 0 for channel A, 1 for channel B
|
||||
* c = the character to print
|
||||
*/
|
||||
void text_put_ansi(short screen, char c) {
|
||||
if (screen < MAX_TEXT_CHANNELS) {
|
||||
/* TODO: magic! */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,9 +78,23 @@ extern void text_set_color(short screen, short foreground, short background);
|
|||
*
|
||||
* Inputs:
|
||||
* screen = the screen number 0 for channel A, 1 for channel B
|
||||
* mode = 0: erase from the cursor to the end of the screen,
|
||||
1: erase from start of the screen to the cursor,
|
||||
2: erase entire screen
|
||||
*/
|
||||
extern void text_clear(short screen, short mode);
|
||||
|
||||
/*
|
||||
* Clear part or all of the current line
|
||||
*
|
||||
* Inputs:
|
||||
* screen = the screen number 0 for channel A, 1 for channel B
|
||||
* mode = 0: erase from the start of the line to the cursor,
|
||||
* 1: erase from cursor to end of the line,
|
||||
* 2: erase entire line
|
||||
*/
|
||||
extern text_clear_line(short screen, short mode);
|
||||
|
||||
/*
|
||||
* Scroll the text screen up one row
|
||||
* Inputs:
|
||||
|
|
|
@ -298,8 +298,9 @@ int main(int argc, char * argv[]) {
|
|||
|
||||
initialize();
|
||||
|
||||
const char * welcome = "\x1B[HFoenix/MCP Command Line Utility... online.\x1B[;2HType \"HELP\" or \"?\" for help.\n";
|
||||
const char * welcome = "\x1B[J\x1B[HFoenix/MCP Command Line Utility... online.\x1B[;2HType \"HELP\" or \"?\" for help.\n";
|
||||
sys_chan_write(0, welcome, strlen(welcome));
|
||||
|
||||
cli_repl(0);
|
||||
|
||||
log(LOG_INFO, "Stopping.");
|
||||
|
|
4321
src/foenixmcp.s68
4321
src/foenixmcp.s68
File diff suppressed because it is too large
Load diff
9617
src/mapfile
9617
src/mapfile
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue