Basic ANSIBBS terminal working. More features needed.
This commit is contained in:
parent
5287b9870e
commit
1de306bef7
4 changed files with 41 additions and 44 deletions
5
LICENSE
5
LICENSE
|
@ -32,6 +32,11 @@ MemWatch
|
||||||
http://www.linkdata.se/sourcecode/memwatch/
|
http://www.linkdata.se/sourcecode/memwatch/
|
||||||
GPL2
|
GPL2
|
||||||
|
|
||||||
|
minicoro
|
||||||
|
--------
|
||||||
|
https://github.com/edubart/minicoro
|
||||||
|
Public Domain or MIT No Attribution
|
||||||
|
|
||||||
SDL2
|
SDL2
|
||||||
----
|
----
|
||||||
https://www.libsdl.org/
|
https://www.libsdl.org/
|
||||||
|
|
|
@ -40,13 +40,17 @@ LINUX_SOURCES = \
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
$$LINUX_INCLUDES \
|
$$LINUX_INCLUDES \
|
||||||
$$PWD/src \
|
$$PWD/src/thirdparty \
|
||||||
$$PWD/src/system \
|
$$PWD/src/system \
|
||||||
$$PWD/src/gui \
|
$$PWD/src/gui \
|
||||||
$$PWD/src/thirdparty
|
$$PWD/src
|
||||||
|
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
$$LINUX_HEADERS \
|
$$LINUX_HEADERS \
|
||||||
|
src/thirdparty/stb_ds.h \
|
||||||
|
src/thirdparty/stb_image.h \
|
||||||
|
src/thirdparty/memwatch/memwatch.h \
|
||||||
|
src/thirdparty/minicoro/minicoro.h \
|
||||||
src/system/memory.h \
|
src/system/memory.h \
|
||||||
src/system/keyboard.h \
|
src/system/keyboard.h \
|
||||||
src/system/task.h \
|
src/system/task.h \
|
||||||
|
@ -56,10 +60,6 @@ HEADERS = \
|
||||||
src/system/mouse.h \
|
src/system/mouse.h \
|
||||||
src/system/vesa.h \
|
src/system/vesa.h \
|
||||||
src/system/os.h \
|
src/system/os.h \
|
||||||
src/thirdparty/stb_ds.h \
|
|
||||||
src/thirdparty/stb_image.h \
|
|
||||||
src/thirdparty/memwatch/memwatch.h \
|
|
||||||
src/thirdparty/minicoro/minicoro.h \
|
|
||||||
src/gui/listbox.h \
|
src/gui/listbox.h \
|
||||||
src/gui/terminal.h \
|
src/gui/terminal.h \
|
||||||
src/gui/updown.h \
|
src/gui/updown.h \
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
|
|
||||||
#define termWrite(...) logWrite(__VA_ARGS__)
|
//#define termWrite(...) logWrite(__VA_ARGS__)
|
||||||
|
#define termWrite(...) while(0){}
|
||||||
|
|
||||||
|
|
||||||
#define TERMINAL_CELL_GET_FLAG(t,x,y,f) (((t)->cells[(x)][(y)].flags & (1 << (f))) != 0)
|
#define TERMINAL_CELL_GET_FLAG(t,x,y,f) (((t)->cells[(x)][(y)].flags & (1 << (f))) != 0)
|
||||||
|
@ -51,7 +52,7 @@ static int16_t terminalConvertToInt(char *number, int16_t defaultValue) {
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
int16_t result = (int16_t)strtol(number, &end, 10);
|
int16_t result = (int16_t)strtol(number, &end, 10);
|
||||||
|
|
||||||
if (end == NULL) result = defaultValue;
|
if (end == NULL || number[0] == 0) result = defaultValue;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ WidgetT *terminalInit(WidgetT *widget, uint16_t cols, uint16_t rows) {
|
||||||
t->base.paintMethod = terminalPaint;
|
t->base.paintMethod = terminalPaint;
|
||||||
t->base.keyboardEventMethod = terminalKeyboardEvent;
|
t->base.keyboardEventMethod = terminalKeyboardEvent;
|
||||||
t->base.mouseEventMethod = terminalMouseEvent;
|
t->base.mouseEventMethod = terminalMouseEvent;
|
||||||
t->font = _guiFont8; // Default font. Also see terminalNew.
|
t->font = _guiFont; // Default font. Also see terminalNew.
|
||||||
t->cols = cols;
|
t->cols = cols;
|
||||||
t->rows = rows;
|
t->rows = rows;
|
||||||
t->cursorX = 1;
|
t->cursorX = 1;
|
||||||
|
@ -167,22 +168,22 @@ WidgetT *terminalInit(WidgetT *widget, uint16_t cols, uint16_t rows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up default palette.
|
// Set up default palette.
|
||||||
t->palette[TERMINAL_COLOR_BLACK] = vbeMakeColor(0x00, 0x00, 0x00);
|
t->palette[TERMINAL_COLOR_BLACK] = vbeMakeColor( 0, 0, 0);
|
||||||
t->palette[TERMINAL_COLOR_BLUE] = vbeMakeColor(0x00, 0x00, 0xAA);
|
t->palette[TERMINAL_COLOR_BLUE] = vbeMakeColor(170, 0, 0);
|
||||||
t->palette[TERMINAL_COLOR_GREEN] = vbeMakeColor(0x00, 0xAA, 0x00);
|
t->palette[TERMINAL_COLOR_GREEN] = vbeMakeColor( 0, 170, 0);
|
||||||
t->palette[TERMINAL_COLOR_CYAN] = vbeMakeColor(0x00, 0xAA, 0xAA);
|
t->palette[TERMINAL_COLOR_CYAN] = vbeMakeColor(170, 85, 0);
|
||||||
t->palette[TERMINAL_COLOR_RED] = vbeMakeColor(0xAA, 0x00, 0x00);
|
t->palette[TERMINAL_COLOR_RED] = vbeMakeColor( 0, 0, 170);
|
||||||
t->palette[TERMINAL_COLOR_MAGENTA] = vbeMakeColor(0xAA, 0x00, 0xAA);
|
t->palette[TERMINAL_COLOR_MAGENTA] = vbeMakeColor(170, 0, 170);
|
||||||
t->palette[TERMINAL_COLOR_BROWN] = vbeMakeColor(0xAA, 0x55, 0x00);
|
t->palette[TERMINAL_COLOR_BROWN] = vbeMakeColor( 0, 170, 170);
|
||||||
t->palette[TERMINAL_COLOR_LIGHT_GRAY] = vbeMakeColor(0xAA, 0xAA, 0xAA);
|
t->palette[TERMINAL_COLOR_LIGHT_GRAY] = vbeMakeColor(170, 170, 170);
|
||||||
t->palette[TERMINAL_COLOR_DARK_GRAY] = vbeMakeColor(0x55, 0x55, 0x55);
|
t->palette[TERMINAL_COLOR_DARK_GRAY] = vbeMakeColor( 85, 85, 85);
|
||||||
t->palette[TERMINAL_COLOR_BRIGHT_BLUE] = vbeMakeColor(0x55, 0x55, 0xFF);
|
t->palette[TERMINAL_COLOR_BRIGHT_BLUE] = vbeMakeColor(255, 85, 85);
|
||||||
t->palette[TERMINAL_COLOR_BRIGHT_GREEN] = vbeMakeColor(0x55, 0xFF, 0x55);
|
t->palette[TERMINAL_COLOR_BRIGHT_GREEN] = vbeMakeColor( 85, 255, 85);
|
||||||
t->palette[TERMINAL_COLOR_BRIGHT_CYAN] = vbeMakeColor(0x55, 0xFF, 0xFF);
|
t->palette[TERMINAL_COLOR_BRIGHT_CYAN] = vbeMakeColor(255, 255, 85);
|
||||||
t->palette[TERMINAL_COLOR_BRIGHT_RED] = vbeMakeColor(0xFF, 0x55, 0x55);
|
t->palette[TERMINAL_COLOR_BRIGHT_RED] = vbeMakeColor( 85, 85, 255);
|
||||||
t->palette[TERMINAL_COLOR_BRIGHT_MAGENTA] = vbeMakeColor(0xFF, 0x55, 0xFF);
|
t->palette[TERMINAL_COLOR_BRIGHT_MAGENTA] = vbeMakeColor(255, 85, 255);
|
||||||
t->palette[TERMINAL_COLOR_YELLOW] = vbeMakeColor(0xFF, 0xFF, 0x55);
|
t->palette[TERMINAL_COLOR_YELLOW] = vbeMakeColor( 85, 255, 255);
|
||||||
t->palette[TERMINAL_COLOR_WHITE] = vbeMakeColor(0xFF, 0xFF, 0xFF);
|
t->palette[TERMINAL_COLOR_WHITE] = vbeMakeColor(255, 255, 255);
|
||||||
|
|
||||||
// Default attributes is gray on black, no bold, no blink, and dirty.
|
// Default attributes is gray on black, no bold, no blink, and dirty.
|
||||||
for (y=0; y<rows; y++) {
|
for (y=0; y<rows; y++) {
|
||||||
|
@ -225,8 +226,8 @@ TerminalT *terminalNew(uint16_t x, uint16_t y, uint16_t cols, uint16_t rows) {
|
||||||
if (!terminal) return NULL;
|
if (!terminal) return NULL;
|
||||||
|
|
||||||
// Default font. Also see terminalInit.
|
// Default font. Also see terminalInit.
|
||||||
w = fontWidthGet(_guiFont8) * cols;
|
w = fontWidthGet(_guiFont) * cols;
|
||||||
h = fontHeightGet(_guiFont8) * rows;
|
h = fontHeightGet(_guiFont) * rows;
|
||||||
|
|
||||||
widget = widgetInit(W(terminal), MAGIC_TERMINAL, x, y, w, h, 0, 0, 0, 0);
|
widget = widgetInit(W(terminal), MAGIC_TERMINAL, x, y, w, h, 0, 0, 0, 0);
|
||||||
if (!widget) {
|
if (!widget) {
|
||||||
|
@ -601,7 +602,8 @@ void terminalPrintChar(TerminalT *terminal, uint8_t c) {
|
||||||
// Cursor restore.
|
// Cursor restore.
|
||||||
case 'u':
|
case 'u':
|
||||||
termWrite("Cursor restore %d %d\n", terminal->saveX, terminal->saveX);
|
termWrite("Cursor restore %d %d\n", terminal->saveX, terminal->saveX);
|
||||||
terminalCursorMove(terminal, terminal->saveX, terminal->saveY);
|
terminal->cursorX = terminal->saveX;
|
||||||
|
terminal->cursorY = terminal->saveY;
|
||||||
terminalSequenceReset(terminal);
|
terminalSequenceReset(terminal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,7 @@ void mainLoop(void *data) {
|
||||||
|
|
||||||
vbeWaitVBlank();
|
vbeWaitVBlank();
|
||||||
vbePresent();
|
vbePresent();
|
||||||
|
taskYield();
|
||||||
} while (key != 27); // Exit on ESC.
|
} while (key != 27); // Exit on ESC.
|
||||||
|
|
||||||
imageUnload(&pointer);
|
imageUnload(&pointer);
|
||||||
|
@ -141,7 +142,6 @@ void terminalTest(void *data) {
|
||||||
FILE *in = NULL;
|
FILE *in = NULL;
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
uint16_t length = 0;
|
uint16_t length = 0;
|
||||||
uint16_t x = 0;
|
|
||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
|
@ -155,17 +155,7 @@ void terminalTest(void *data) {
|
||||||
fclose(in);
|
fclose(in);
|
||||||
buffer[length] = 0;
|
buffer[length] = 0;
|
||||||
|
|
||||||
logWrite("ANSI loaded.\n");
|
terminalPrint(t1, buffer);
|
||||||
|
|
||||||
while (x < length) {
|
|
||||||
if (lastKey == 27) break;
|
|
||||||
// if (lastKey == ' ') {
|
|
||||||
lastKey = 0;
|
|
||||||
terminalPrintChar(t1, buffer[x]);
|
|
||||||
x++;
|
|
||||||
// }
|
|
||||||
taskYield();
|
|
||||||
}
|
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +192,7 @@ void test(void *data) {
|
||||||
guiAttach(W(desktop), W(w2));
|
guiAttach(W(desktop), W(w2));
|
||||||
w3 = windowNew(300, 300, 300, 200, "Window 3");
|
w3 = windowNew(300, 300, 300, 200, "Window 3");
|
||||||
guiAttach(W(desktop), W(w3));
|
guiAttach(W(desktop), W(w3));
|
||||||
w4 = windowNew(10, 10, 7 + 8 + (80 * 8), 26 + 8 + (24 * 8), "Terminal");
|
w4 = windowNew(10, 10, 7 + 8 + (80 * 8), 26 + 8 + (24 * 14), "Terminal");
|
||||||
guiAttach(W(desktop), W(w4));
|
guiAttach(W(desktop), W(w4));
|
||||||
|
|
||||||
// Window 1
|
// Window 1
|
||||||
|
@ -260,7 +250,7 @@ void test(void *data) {
|
||||||
t1 = terminalNew(0, 0, 80, 24);
|
t1 = terminalNew(0, 0, 80, 24);
|
||||||
guiAttach(W(w4), W(t1));
|
guiAttach(W(w4), W(t1));
|
||||||
|
|
||||||
taskCreate(terminalTest, NULL);
|
taskCreate(terminalTest, "terminalTest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,8 +309,8 @@ int main(int argc, char *argv[]) {
|
||||||
guiStartup();
|
guiStartup();
|
||||||
taskStartup();
|
taskStartup();
|
||||||
|
|
||||||
taskCreate(test, NULL);
|
taskCreate(test, "test");
|
||||||
taskCreate(mainLoop, NULL);
|
taskCreate(mainLoop, "mainLoop");
|
||||||
taskRun();
|
taskRun();
|
||||||
|
|
||||||
taskShutdown();
|
taskShutdown();
|
||||||
|
|
Loading…
Add table
Reference in a new issue