mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-20 16:15:15 +00:00
Merge pull request #97 from QB64Team/nix-terminal
Minimal terminal features for *nix systems
This commit is contained in:
commit
54bc1595a1
|
@ -7401,14 +7401,29 @@ void qbg_sub_color(uint32 col1,uint32 col2,uint32 bordercolor,int32 passed){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QB64_WINDOWS
|
|
||||||
if (write_page->console){
|
if (write_page->console){
|
||||||
|
#ifdef QB64_WINDOWS
|
||||||
HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
int color = col2 * 16 + col1;
|
int color = col2 * 16 + col1;
|
||||||
SetConsoleTextAttribute(output, color);
|
SetConsoleTextAttribute(output, color);
|
||||||
|
#else
|
||||||
|
// Exactly how the colour is rendered depends on your terminal emulator and
|
||||||
|
// colour palette. Themes and user-customisation aside, the first 16 colours
|
||||||
|
// line up with the old VGA colour scheme.
|
||||||
|
// Most terminal emulators can handle 8 bit colour, see
|
||||||
|
// https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit for the 8 bit colour palette.
|
||||||
|
if ((passed & 1 && (col1 > 255 || col1 < 0))
|
||||||
|
|| (passed & 2 && (col2 > 255 || col2 < 0)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (passed & 1)
|
||||||
|
printf("\033[38;5;%dm", col1);
|
||||||
|
|
||||||
|
if (passed & 2)
|
||||||
|
printf("\033[48;5;%dm", col2);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (write_page->compatible_mode==32){
|
if (write_page->compatible_mode==32){
|
||||||
if (passed&4) goto error;
|
if (passed&4) goto error;
|
||||||
|
@ -11199,7 +11214,9 @@ void sub_cls(int32 method,uint32 use_color,int32 passed){
|
||||||
system("cls"); //lazy but works
|
system("cls"); //lazy but works
|
||||||
qbg_sub_locate(1, 1, 0, 0, 0, 3); //is this really necessary?
|
qbg_sub_locate(1, 1, 0, 0, 0, 3); //is this really necessary?
|
||||||
#else
|
#else
|
||||||
system("clear");
|
if (passed&2) qbg_sub_color(0, use_color, 0, 2);
|
||||||
|
cout<<"\033[2J";
|
||||||
|
qbg_sub_locate(1, 1, 0, 0, 0, 3);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -11371,8 +11388,8 @@ void qbg_sub_locate(int32 row,int32 column,int32 cursor,int32 start,int32 stop,i
|
||||||
static int32 h,w,i;
|
static int32 h,w,i;
|
||||||
if (new_error) return;
|
if (new_error) return;
|
||||||
|
|
||||||
#ifdef QB64_WINDOWS //If trying to locate with windows console
|
|
||||||
if (write_page->console){
|
if (write_page->console){
|
||||||
|
#ifdef QB64_WINDOWS //If trying to locate with windows console
|
||||||
CONSOLE_SCREEN_BUFFER_INFO cl_bufinfo;
|
CONSOLE_SCREEN_BUFFER_INFO cl_bufinfo;
|
||||||
SECURITY_ATTRIBUTES SecAttribs = {sizeof(SECURITY_ATTRIBUTES), 0, 1};
|
SECURITY_ATTRIBUTES SecAttribs = {sizeof(SECURITY_ATTRIBUTES), 0, 1};
|
||||||
HANDLE cl_conout = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0);
|
HANDLE cl_conout = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0);
|
||||||
|
@ -11382,9 +11399,15 @@ void qbg_sub_locate(int32 row,int32 column,int32 cursor,int32 start,int32 stop,i
|
||||||
COORD pos = {column-1, row-1};
|
COORD pos = {column-1, row-1};
|
||||||
HANDLE output = GetStdHandle (STD_OUTPUT_HANDLE);
|
HANDLE output = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||||
SetConsoleCursorPosition(output, pos);
|
SetConsoleCursorPosition(output, pos);
|
||||||
|
#else
|
||||||
|
// We don't have a good way of getting the current cursor position, so we ignore any LOCATEs
|
||||||
|
// that don't give an absolute position.
|
||||||
|
if (!(passed & 1 && passed & 2))
|
||||||
|
return;
|
||||||
|
printf("\033[%d;%dH", row, column);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//calculate height & width in characters
|
//calculate height & width in characters
|
||||||
if (write_page->compatible_mode){
|
if (write_page->compatible_mode){
|
||||||
|
|
Loading…
Reference in a new issue