From 1eb942c8a34166e43f43c843f09bb48ba40b65b2 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 20 Sep 2009 14:23:45 +0200 Subject: We now have scrollable virtual terminals ! --- Source/Kernel/Config.h | 3 + Source/Kernel/Core/Sys.ns.cpp | 19 +- Source/Kernel/Core/Sys.ns.h | 1 + Source/Kernel/Core/kmain.wtf.cpp | 15 +- Source/Kernel/DeviceManager/Kbd.ns.cpp | 2 +- Source/Kernel/Library/ByteArray.class.h | 2 +- Source/Kernel/Library/WChar.class.h | 4 + Source/Kernel/Makefile | 6 +- Source/Kernel/Melon.ke | Bin 168414 -> 174342 bytes Source/Kernel/MemoryManager/PhysMem.ns.cpp | 2 +- Source/Kernel/Ressources/Graphics/logo.text.cxd | 10 ++ Source/Kernel/Ressources/Info.txt | 5 - Source/Kernel/Ressources/Keymaps/fr.cxd | 56 ++++++ Source/Kernel/Ressources/Texts/Info.txt | 5 + Source/Kernel/Ressources/Texts/Welcome.txt | 12 ++ Source/Kernel/Ressources/Welcome.txt | 12 -- Source/Kernel/Ressources/keymap-fr.wtf.cxd | 56 ------ Source/Kernel/Ressources/logo.cxd | 10 -- Source/Kernel/SyscallManager/IDT.ns.cpp | 2 +- Source/Kernel/TaskManager/Process.class.h | 2 +- Source/Kernel/TaskManager/Task.ns.h | 2 +- Source/Kernel/VTManager/ScrollableVT.class.cpp | 94 ++++++++++ Source/Kernel/VTManager/ScrollableVT.class.h | 24 +++ Source/Kernel/VTManager/SimpleVT.class.cpp | 135 ++++++++++++++ Source/Kernel/VTManager/SimpleVT.class.h | 42 +++++ Source/Kernel/VTManager/VT.ns.cpp | 6 +- Source/Kernel/VTManager/VT.ns.h | 6 +- .../Kernel/VTManager/VirtualTerminal-kbd.class.cpp | 73 -------- .../Kernel/VTManager/VirtualTerminal-kbd.proto.cpp | 73 ++++++++ Source/Kernel/VTManager/VirtualTerminal.class.cpp | 196 --------------------- Source/Kernel/VTManager/VirtualTerminal.class.h | 67 ------- Source/Kernel/VTManager/VirtualTerminal.proto.cpp | 74 ++++++++ Source/Kernel/VTManager/VirtualTerminal.proto.h | 51 ++++++ 33 files changed, 625 insertions(+), 442 deletions(-) create mode 100644 Source/Kernel/Ressources/Graphics/logo.text.cxd delete mode 100644 Source/Kernel/Ressources/Info.txt create mode 100644 Source/Kernel/Ressources/Keymaps/fr.cxd create mode 100644 Source/Kernel/Ressources/Texts/Info.txt create mode 100644 Source/Kernel/Ressources/Texts/Welcome.txt delete mode 100644 Source/Kernel/Ressources/Welcome.txt delete mode 100644 Source/Kernel/Ressources/keymap-fr.wtf.cxd delete mode 100644 Source/Kernel/Ressources/logo.cxd create mode 100644 Source/Kernel/VTManager/ScrollableVT.class.cpp create mode 100644 Source/Kernel/VTManager/ScrollableVT.class.h create mode 100644 Source/Kernel/VTManager/SimpleVT.class.cpp create mode 100644 Source/Kernel/VTManager/SimpleVT.class.h delete mode 100644 Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp create mode 100644 Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp delete mode 100644 Source/Kernel/VTManager/VirtualTerminal.class.cpp delete mode 100644 Source/Kernel/VTManager/VirtualTerminal.class.h create mode 100644 Source/Kernel/VTManager/VirtualTerminal.proto.cpp create mode 100644 Source/Kernel/VTManager/VirtualTerminal.proto.h (limited to 'Source/Kernel') diff --git a/Source/Kernel/Config.h b/Source/Kernel/Config.h index 2767104..09c7a14 100644 --- a/Source/Kernel/Config.h +++ b/Source/Kernel/Config.h @@ -1,6 +1,9 @@ #ifndef DEF_MELON_KERNEL_CONFIG #define DEF_MELON_KERNEL_CONFIG +#define THIS_IS_MELON +#undef THIS_IS_NOT_MELON + #define OPT_DEBUG //Color scheme diff --git a/Source/Kernel/Core/Sys.ns.cpp b/Source/Kernel/Core/Sys.ns.cpp index ab57589..081e7a5 100644 --- a/Source/Kernel/Core/Sys.ns.cpp +++ b/Source/Kernel/Core/Sys.ns.cpp @@ -1,9 +1,10 @@ //This automatically includes Sys.ns.h #include -#include +#include +#include #include -#define DEBUGVT(x) VirtualTerminal *x = new VirtualTerminal(4, 56, 0, 15); x->map(); x->put('\n'); +#define DEBUGVT(x) SimpleVT *x = new SimpleVT(4, 56, 0, 15); x->map(); x->put('\n'); using namespace CMem; @@ -81,7 +82,7 @@ void panic(char *message, char *file, u32int line) { void panic(char *message, registers_t *regs, char *file, u32int line) { asm volatile("cli"); - VirtualTerminal vt(20, 70, 7, 1); + SimpleVT vt(20, 70, 7, 1); vt.map(); vt << "PANIC : " << message << "\n => in " << file << " at " << (s32int)line << "\n\n"; @@ -115,7 +116,19 @@ void panic_assert(char *file, u32int line, char *desc) { } void reboot() { + asm volatile("cli"); + Log::close(); outb(0x64, 0xFE); } +void halt() { + asm volatile("cli"); + Log::close(); + String message("MELON SEZ : KTHXBYE, IOU CAN NAOW TURNZ OFF UR COMPUTER."); + SimpleVT vt(3, message.size() + 16, 6, 0); + vt.map(); + vt << "\n\t" << message; + while (1) asm volatile("cli"); +} + } diff --git a/Source/Kernel/Core/Sys.ns.h b/Source/Kernel/Core/Sys.ns.h index a205892..6779585 100644 --- a/Source/Kernel/Core/Sys.ns.h +++ b/Source/Kernel/Core/Sys.ns.h @@ -31,6 +31,7 @@ namespace Sys { void bochs_output(String message, char *file, u32int line); void bochs_output_hex(u32int i); void reboot(); + void halt(); } #endif diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp index e3ef2fd..4c576b6 100644 --- a/Source/Kernel/Core/kmain.wtf.cpp +++ b/Source/Kernel/Core/kmain.wtf.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include extern u32int end; //Placement address @@ -65,7 +65,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) { Disp::setDisplay(vgaout); //Create a VT for handling the Melon bootup logo - VirtualTerminal *melonLogoVT = new VirtualTerminal(melonLogoLines, melonLogoCols, TXTLOGO_FGCOLOR, TXTLOGO_BGCOLOR); + SimpleVT *melonLogoVT = new SimpleVT(melonLogoLines, melonLogoCols, TXTLOGO_FGCOLOR, TXTLOGO_BGCOLOR); for (int i = 0; i < melonLogoLines; i++) { for (int j = 0; j < melonLogoCols; j++) { melonLogoVT->putChar(i, j, melonLogo[i][j]); @@ -74,7 +74,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) { melonLogoVT->map(1); //Create a VT for logging what kernel does - VirtualTerminal *kvt = new VirtualTerminal(15, 76, KVT_FGCOLOR, KVT_BGCOLOR); + SimpleVT *kvt = new ScrollableVT(15, 76, 100, KVT_FGCOLOR, KVT_BGCOLOR); kvt->map(melonLogoLines + 2); INFO(kvt); *kvt << "Lower ram : " << (s32int)mbd->mem_lower << "k, upper : " << (s32int)mbd->mem_upper << "k.\n"; @@ -116,7 +116,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) { Log::log(KL_STATUS, "kmain : Registered textual VGA output"); Dev::registerDevice(new PS2Keyboard()); //Initialize keyboard driver - Kbd::setKeymap(keymapFR_normal, keymapFR_shift, keymapFR_caps, keymapFR_altgr, keymapFR_shiftaltgr); //Load keymap + Kbd::setKeymap(keymap_normal, keymap_shift, keymap_caps, keymap_altgr, keymap_shiftaltgr); //Load keymap Kbd::setFocus(kvt); //Set focus to virtual terminal Log::log(KL_STATUS, "kmain : Keyboard set up"); @@ -135,6 +135,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) { *kvt << " - Command list for integrated kernel shell:\n"; *kvt << " - help shows this help screen\n"; *kvt << " - reboot reboots your computer\n"; + *kvt << " - halt shuts down your computer\n"; *kvt << " - panic causes a kernel panic\n"; *kvt << " - devices shows all detected devices on your computer\n"; *kvt << " - free shows memory usage (physical frames and kernel heap)\n"; @@ -143,6 +144,8 @@ void kmain(multiboot_info_t* mbd, u32int magic) { *kvt << " - Commands you should know how to use : ls, cd, cat, pwd, rm, mkdir, wf\n"; } else if (tokens[0] == "reboot") { Sys::reboot(); + } else if (tokens[0] == "halt") { + Sys::halt(); } else if (tokens[0] == "panic") { PANIC("This is what happens when you say 'panic'."); } else if (tokens[0] == "ls") { diff --git a/Source/Kernel/DeviceManager/Kbd.ns.cpp b/Source/Kernel/DeviceManager/Kbd.ns.cpp index 95a97e3..fddf0dd 100644 --- a/Source/Kernel/DeviceManager/Kbd.ns.cpp +++ b/Source/Kernel/DeviceManager/Kbd.ns.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include namespace Kbd { diff --git a/Source/Kernel/Library/ByteArray.class.h b/Source/Kernel/Library/ByteArray.class.h index f5214b3..a6d594f 100644 --- a/Source/Kernel/Library/ByteArray.class.h +++ b/Source/Kernel/Library/ByteArray.class.h @@ -2,7 +2,7 @@ #define DEF_BYTEARRAY_CLASS_H #include -#include +#include class ByteArray : public BasicString { public: diff --git a/Source/Kernel/Library/WChar.class.h b/Source/Kernel/Library/WChar.class.h index ba94a23..e4da603 100644 --- a/Source/Kernel/Library/WChar.class.h +++ b/Source/Kernel/Library/WChar.class.h @@ -1,7 +1,11 @@ #ifndef DEF_UCHAR_CLASS_H #define DEF_UCHAR_CLASS_H +#include + +#ifndef THIS_IS_NOT_MELON #include +#endif enum { UE_UTF8, diff --git a/Source/Kernel/Makefile b/Source/Kernel/Makefile index e68d12b..7f6fa56 100644 --- a/Source/Kernel/Makefile +++ b/Source/Kernel/Makefile @@ -31,8 +31,10 @@ Objects = Core/loader.wtf.o \ TaskManager/Task.ns.o \ TaskManager/Task.wtf.o \ TaskManager/Mutex.class.o \ - VTManager/VirtualTerminal.class.o \ - VTManager/VirtualTerminal-kbd.class.o \ + VTManager/VirtualTerminal.proto.o \ + VTManager/SimpleVT.class.o \ + VTManager/ScrollableVT.class.o \ + VTManager/VirtualTerminal-kbd.proto.o \ VTManager/VT.ns.o \ Library/Bitset.class.o \ Library/String.class.o \ diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke index de3493a..b1dfb42 100755 Binary files a/Source/Kernel/Melon.ke and b/Source/Kernel/Melon.ke differ diff --git a/Source/Kernel/MemoryManager/PhysMem.ns.cpp b/Source/Kernel/MemoryManager/PhysMem.ns.cpp index 08fa882..1794106 100644 --- a/Source/Kernel/MemoryManager/PhysMem.ns.cpp +++ b/Source/Kernel/MemoryManager/PhysMem.ns.cpp @@ -1,6 +1,6 @@ #include "PhysMem.ns.h" #include -#include +#include PageDirectory* kernelPageDirectory; diff --git a/Source/Kernel/Ressources/Graphics/logo.text.cxd b/Source/Kernel/Ressources/Graphics/logo.text.cxd new file mode 100644 index 0000000..6cacdb1 --- /dev/null +++ b/Source/Kernel/Ressources/Graphics/logo.text.cxd @@ -0,0 +1,10 @@ +char *melonLogo[] = { +" THE //|| //// ", +" // || // // //==// // /====/ //| // ", +" // || // // // // // // // //|| // ", +" // |// // //==// // // // // || // ", +" // // // // // // // ||// ", +" // // //==== //==== /====/ // |// ", +" OPERATING SYSTEM " +}; +int melonLogoLines = 7, melonLogoCols = 60; diff --git a/Source/Kernel/Ressources/Info.txt b/Source/Kernel/Ressources/Info.txt deleted file mode 100644 index 1a57fc9..0000000 --- a/Source/Kernel/Ressources/Info.txt +++ /dev/null @@ -1,5 +0,0 @@ -These files were just added here for fun. - -Oh, you wanted to know what the wf command meant ? -Simple : it means Write File. Type 'wf filename' and then enter the -file's contents, ending with . diff --git a/Source/Kernel/Ressources/Keymaps/fr.cxd b/Source/Kernel/Ressources/Keymaps/fr.cxd new file mode 100644 index 0000000..8cfdf8c --- /dev/null +++ b/Source/Kernel/Ressources/Keymaps/fr.cxd @@ -0,0 +1,56 @@ +//This file is precious !!! Very precious !! + +WChar keymap_normal[128] = { +/* 0x00 */ "", "", "&", "é", "\"", "'", "(", "-", "è", "_", "ç", "à", ")", "=", "", "", +/* 0x10 */ "a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "^", "$", "", "", "q", "s", +/* 0x20 */ "d", "f", "g", "h", "j", "k", "l", "m", "ù", "²", "", "*", "w", "x", "c", "v", +/* 0x30 */ "b", "n", ",", ";", ":", "!", "", "*", "", " ", "", "", "", "", "", "", +/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", +/* 0x50 */ "", "", "", "", "", "", "<", "", "", "", "", "", "", "", "", "", +/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" +}; + +WChar keymap_shift[128] = { +/* 0x00 */ "", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "°", "+", "", "", +/* 0x10 */ "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "¨", "£", "", "", "Q", "S", +/* 0x20 */ "D", "F", "G", "H", "J", "K", "L", "M", "%", "~", "", "µ", "W", "X", "C", "V", +/* 0x30 */ "B", "N", "?", ".", "/", "§", "", "*", "", " ", "", "", "", "", "", "", +/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", +/* 0x50 */ "", "", "", "", "", "", ">", "", "", "", "", "", "", "", "", "", +/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +}; + +WChar keymap_caps[128] = { +/* 0x00 */ "", "", "&", "É", "\"", "'", "(", "-", "È", "_", "Ç", "À", ")", "=", "", "", +/* 0x10 */ "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "¨", "$", "", "", "Q", "S", +/* 0x20 */ "D", "F", "G", "H", "J", "K", "L", "M", "Ù", "²", "", "*", "W", "X", "C", "V", +/* 0x30 */ "B", "N", ",", ";", ":", "!", "", "*", "", " ", "", "", "", "", "", "", +/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", +/* 0x50 */ "", "", "", "", "", "", ">", "", "", "", "", "", "", "", "", "", +/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +}; + +WChar keymap_altgr[128] = { +/* 0x00 */ "", "", "¹", "~", "#", "{", "[", "|", "`", "\\", "^", "@", "]", "}", "", "", +/* 0x10 */ "æ", "«", "€", "¶", "ŧ", "←", "↓", "→", "ø", "þ", "¨", "¤", "", "", "@", "ß", +/* 0x20 */ "ð", "đ", "ŋ", "ħ", "j", "ĸ", "ł", "µ", "^", "¬", "", "`", "ł", "»", "¢", "“", +/* 0x30 */ "”", "n", "´", ";", "·", "!", "", "*", "", " ", "", "", "", "", "", "", +/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", +/* 0x50 */ "", "", "", "", "", "", "|", "", "", "", "", "", "", "", "", "", +/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +}; + +WChar keymap_shiftaltgr[128] = { +/* 0x00 */ "", "", "¡", "⅛", "£", "$", "⅜", "⅝", "⅞", "™", "±", "°", "¿", "˛", "", "", +/* 0x10 */ "Æ", "<", "¢", "®", "Ŧ", "¥", "↑", "ı", "Ø", "Þ", "°", "¯", "", "", "Ω", "§", +/* 0x20 */ "Ð", "ª", "Ŋ", "Ħ", "J", "&", "Ł", "º", "ˇ", "¬", "", "˘", "Ł", ">", "©", "‘", +/* 0x30 */ "’", "N", "˝", "×", "÷", "˙", "", "*", "", " ", "", "", "", "", "", "", +/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", +/* 0x50 */ "", "", "", "", "", "", "¦", "", "", "", "", "", "", "", "", "", +/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +}; diff --git a/Source/Kernel/Ressources/Texts/Info.txt b/Source/Kernel/Ressources/Texts/Info.txt new file mode 100644 index 0000000..1a57fc9 --- /dev/null +++ b/Source/Kernel/Ressources/Texts/Info.txt @@ -0,0 +1,5 @@ +These files were just added here for fun. + +Oh, you wanted to know what the wf command meant ? +Simple : it means Write File. Type 'wf filename' and then enter the +file's contents, ending with . diff --git a/Source/Kernel/Ressources/Texts/Welcome.txt b/Source/Kernel/Ressources/Texts/Welcome.txt new file mode 100644 index 0000000..67bb8b2 --- /dev/null +++ b/Source/Kernel/Ressources/Texts/Welcome.txt @@ -0,0 +1,12 @@ +EN : +Welcome to this Melon live-floppy ! For the moment, the project isn't very +advanced, but if you can read this text, it's already because of a lot of +great efforts I've made in Melon's developpment. + +FR : +Bienvenue sur cette live-disquette de Melon ! Pour l'instant, le projet +n'est pas très avancé, mais si vous pouvez lire ce texte, c'est déjà grâce +à un grand travail de ma part dans le développement de Melon. + +ES : +[I can't speak Spanish properly, sorry] diff --git a/Source/Kernel/Ressources/Welcome.txt b/Source/Kernel/Ressources/Welcome.txt deleted file mode 100644 index 67bb8b2..0000000 --- a/Source/Kernel/Ressources/Welcome.txt +++ /dev/null @@ -1,12 +0,0 @@ -EN : -Welcome to this Melon live-floppy ! For the moment, the project isn't very -advanced, but if you can read this text, it's already because of a lot of -great efforts I've made in Melon's developpment. - -FR : -Bienvenue sur cette live-disquette de Melon ! Pour l'instant, le projet -n'est pas très avancé, mais si vous pouvez lire ce texte, c'est déjà grâce -à un grand travail de ma part dans le développement de Melon. - -ES : -[I can't speak Spanish properly, sorry] diff --git a/Source/Kernel/Ressources/keymap-fr.wtf.cxd b/Source/Kernel/Ressources/keymap-fr.wtf.cxd deleted file mode 100644 index f24c14d..0000000 --- a/Source/Kernel/Ressources/keymap-fr.wtf.cxd +++ /dev/null @@ -1,56 +0,0 @@ -//This file is precious !!! Very precious !! - -WChar keymapFR_normal[128] = { -/* 0x00 */ "", "", "&", "é", "\"", "'", "(", "-", "è", "_", "ç", "à", ")", "=", "", "", -/* 0x10 */ "a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "^", "$", "", "", "q", "s", -/* 0x20 */ "d", "f", "g", "h", "j", "k", "l", "m", "ù", "²", "", "*", "w", "x", "c", "v", -/* 0x30 */ "b", "n", ",", ";", ":", "!", "", "*", "", " ", "", "", "", "", "", "", -/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", -/* 0x50 */ "", "", "", "", "", "", "<", "", "", "", "", "", "", "", "", "", -/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" -}; - -WChar keymapFR_shift[128] = { -/* 0x00 */ "", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "°", "+", "", "", -/* 0x10 */ "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "¨", "£", "", "", "Q", "S", -/* 0x20 */ "D", "F", "G", "H", "J", "K", "L", "M", "%", "~", "", "µ", "W", "X", "C", "V", -/* 0x30 */ "B", "N", "?", ".", "/", "§", "", "*", "", " ", "", "", "", "", "", "", -/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", -/* 0x50 */ "", "", "", "", "", "", ">", "", "", "", "", "", "", "", "", "", -/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -}; - -WChar keymapFR_caps[128] = { -/* 0x00 */ "", "", "&", "É", "\"", "'", "(", "-", "È", "_", "Ç", "À", ")", "=", "", "", -/* 0x10 */ "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "¨", "$", "", "", "Q", "S", -/* 0x20 */ "D", "F", "G", "H", "J", "K", "L", "M", "Ù", "²", "", "*", "W", "X", "C", "V", -/* 0x30 */ "B", "N", ",", ";", ":", "!", "", "*", "", " ", "", "", "", "", "", "", -/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", -/* 0x50 */ "", "", "", "", "", "", ">", "", "", "", "", "", "", "", "", "", -/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -}; - -WChar keymapFR_altgr[128] = { -/* 0x00 */ "", "", "¹", "~", "#", "{", "[", "|", "`", "\\", "^", "@", "]", "}", "", "", -/* 0x10 */ "æ", "«", "€", "¶", "ŧ", "←", "↓", "→", "ø", "þ", "¨", "¤", "", "", "@", "ß", -/* 0x20 */ "ð", "đ", "ŋ", "ħ", "j", "ĸ", "ł", "µ", "^", "¬", "", "`", "ł", "»", "¢", "“", -/* 0x30 */ "”", "n", "´", ";", "·", "!", "", "*", "", " ", "", "", "", "", "", "", -/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", -/* 0x50 */ "", "", "", "", "", "", "|", "", "", "", "", "", "", "", "", "", -/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -}; - -WChar keymapFR_shiftaltgr[128] = { -/* 0x00 */ "", "", "¡", "⅛", "£", "$", "⅜", "⅝", "⅞", "™", "±", "°", "¿", "˛", "", "", -/* 0x10 */ "Æ", "<", "¢", "®", "Ŧ", "¥", "↑", "ı", "Ø", "Þ", "°", "¯", "", "", "Ω", "§", -/* 0x20 */ "Ð", "ª", "Ŋ", "Ħ", "J", "&", "Ł", "º", "ˇ", "¬", "", "˘", "Ł", ">", "©", "‘", -/* 0x30 */ "’", "N", "˝", "×", "÷", "˙", "", "*", "", " ", "", "", "", "", "", "", -/* 0x40 */ "", "", "", "", "", "", "", "", "", "", "-", "", "", "", "+", "", -/* 0x50 */ "", "", "", "", "", "", "¦", "", "", "", "", "", "", "", "", "", -/* 0x60 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -/* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -}; diff --git a/Source/Kernel/Ressources/logo.cxd b/Source/Kernel/Ressources/logo.cxd deleted file mode 100644 index 6cacdb1..0000000 --- a/Source/Kernel/Ressources/logo.cxd +++ /dev/null @@ -1,10 +0,0 @@ -char *melonLogo[] = { -" THE //|| //// ", -" // || // // //==// // /====/ //| // ", -" // || // // // // // // // //|| // ", -" // |// // //==// // // // // || // ", -" // // // // // // // ||// ", -" // // //==== //==== /====/ // |// ", -" OPERATING SYSTEM " -}; -int melonLogoLines = 7, melonLogoCols = 60; diff --git a/Source/Kernel/SyscallManager/IDT.ns.cpp b/Source/Kernel/SyscallManager/IDT.ns.cpp index a27dfa9..4f41fb2 100644 --- a/Source/Kernel/SyscallManager/IDT.ns.cpp +++ b/Source/Kernel/SyscallManager/IDT.ns.cpp @@ -1,5 +1,5 @@ #include "IDT.ns.h" -#include +#include #include #include diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h index 8b0a030..65a5d8b 100644 --- a/Source/Kernel/TaskManager/Process.class.h +++ b/Source/Kernel/TaskManager/Process.class.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #define P_ZOMBIE 0 #define P_RUNNING 1 diff --git a/Source/Kernel/TaskManager/Task.ns.h b/Source/Kernel/TaskManager/Task.ns.h index db7933c..634d103 100644 --- a/Source/Kernel/TaskManager/Task.ns.h +++ b/Source/Kernel/TaskManager/Task.ns.h @@ -2,7 +2,7 @@ #define DEF_TASK_NS_H #include -#include +#include namespace Task { extern Thread* currentThread; diff --git a/Source/Kernel/VTManager/ScrollableVT.class.cpp b/Source/Kernel/VTManager/ScrollableVT.class.cpp new file mode 100644 index 0000000..ca0075a --- /dev/null +++ b/Source/Kernel/VTManager/ScrollableVT.class.cpp @@ -0,0 +1,94 @@ +#include "ScrollableVT.class.h" +#include +#include + +#define BUFCHR(l, c) m_buff[((l) * m_cols) + (c)] + +ScrollableVT::ScrollableVT(u32int rows, u32int cols, u32int keepRows, u8int fgcolor, u8int bgcolor) : + SimpleVT(rows, cols, fgcolor, bgcolor) { + m_keeprows = keepRows; + m_linesup = 0; + m_lines = new vtchr* [keepRows]; + for (u32int i = 0; i < keepRows; i++) { + m_lines[i] = new vtchr [cols]; + for (u32int j = 0; j < cols; j++) { + m_lines[i][j].color = m_color; + m_lines[i][j].c = " "; + } + } +} + +ScrollableVT::~ScrollableVT() { + for (u32int i = 0; i < m_keeprows; i++) { + delete m_lines[i]; + } + delete m_lines; +} + +void ScrollableVT::putChar(u32int row, u32int col, WChar c) { + if (row >= m_rows or col >= m_cols) return; + vtchr* ch = &BUFCHR(row, col); + ch->c = c; + ch->color = m_color; + if (m_mapped) { + if (row + m_linesup < m_rows) + Disp::putChar(row + m_maprow + m_linesup, col + m_mapcol, BUFCHR(row, col).c, m_color); + } +} + +void ScrollableVT::updateCursor() { + if (m_csrlin + m_linesup < m_rows) + Disp::moveCursor(m_csrlin + m_maprow + m_linesup, m_csrcol + m_mapcol); +} + +void ScrollableVT::redraw() { + if (!m_mapped) return; + for (u32int r = 0; r < m_rows; r++) { + if (r >= m_linesup) { + for (u32int c = 0; c < m_cols; c++) { + Disp::putChar(r + m_maprow, c + m_mapcol, BUFCHR(r - m_linesup, c).c, BUFCHR(r - m_linesup, c).color); + } + } else { + for (u32int c = 0; c < m_cols; c++) { + register u32int l = m_keeprows - m_linesup + r; + Disp::putChar(r + m_maprow, c + m_mapcol, m_lines[l][c].c, m_lines[l][c].color); + } + } + } +} + +void ScrollableVT::scroll() { + for (u32int c = 0; c < m_cols; c++) { + m_lines[0][c] = BUFCHR(0, c); + } + vtchr* x = m_lines[0]; + for (u32int l = 1; l < m_keeprows; l++) { + m_lines[l - 1] = m_lines[l]; + } + m_lines[m_keeprows - 1] = x; + SimpleVT::scroll(); +} + +void ScrollableVT::keyPress(Kbd::keypress_t kp) { + if (kp.hascmd && kp.modifiers == STATUS_SHIFT) { + s32int nlup = m_linesup; + if (kp.command == KBDC_PGUP) { + nlup = m_linesup + (m_rows - 2); + } else if (kp.command == KBDC_PGDOWN) { + nlup = m_linesup - (m_rows - 2); + } else if (kp.command == KBDC_UP) { + nlup = m_linesup + 1; + } else if (kp.command == KBDC_DOWN) { + nlup = m_linesup - 1; + } else { + VirtualTerminal::keyPress(kp); + } + if (nlup < 0) nlup = 0; + m_linesup = nlup; + if (m_linesup > m_keeprows) m_linesup = m_keeprows; + redraw(); + updateCursor(); + } else { + VirtualTerminal::keyPress(kp); + } +} diff --git a/Source/Kernel/VTManager/ScrollableVT.class.h b/Source/Kernel/VTManager/ScrollableVT.class.h new file mode 100644 index 0000000..fbc2c4c --- /dev/null +++ b/Source/Kernel/VTManager/ScrollableVT.class.h @@ -0,0 +1,24 @@ +#ifndef DEF_SCROLLABLEVT_CLASS_H +#define DEF_SCROLLABLEVT_CLASS_H + +#include + +class ScrollableVT : public SimpleVT { + private: + vtchr **m_lines; + u32int m_keeprows; + u32int m_linesup; + + public: + ScrollableVT(u32int rows, u32int cols, u32int keepRows, u8int fgcolor = 7, u8int bgcolor = 0); + virtual ~ScrollableVT(); + + virtual void putChar(u32int row, u32int col, WChar c); + void updateCursor(); + void redraw(); + void scroll(); + + void keyPress(Kbd::keypress_t kp); +}; + +#endif diff --git a/Source/Kernel/VTManager/SimpleVT.class.cpp b/Source/Kernel/VTManager/SimpleVT.class.cpp new file mode 100644 index 0000000..9639d50 --- /dev/null +++ b/Source/Kernel/VTManager/SimpleVT.class.cpp @@ -0,0 +1,135 @@ +#include "SimpleVT.class.h" +#include +#include + +#define BUFCHR(l, c) m_buff[((l) * m_cols) + (c)] + +SimpleVT::SimpleVT(u32int rows, u32int cols, u8int fgcolor, u8int bgcolor) : VirtualTerminal() { + m_buff = new vtchr[rows * cols]; + m_rows = rows; + m_cols = cols; + m_mapped = false; + setColor(fgcolor, bgcolor); + clear(); + + m_csrcol = 0; + m_csrlin = 0; +} + +SimpleVT::~SimpleVT() { + if (m_mapped) VT::unmap(this); + delete [] m_buff; +} + +void SimpleVT::setColor(u8int fgcolor, u8int bgcolor) { + if (bgcolor == 0xFF) { + m_color = (m_color & 0xF0) | fgcolor; + } else { + m_color = (bgcolor << 4) | fgcolor; + } +} + +void SimpleVT::putChar(u32int row, u32int col, WChar c) { + if (row >= m_rows or col >= m_cols) return; + vtchr* ch = &BUFCHR(row, col); + ch->c = c; + ch->color = m_color; + if (m_mapped) + Disp::putChar(row + m_maprow, col + m_mapcol, BUFCHR(row, col).c, m_color); +} + +void SimpleVT::clear() { + for (u32int i = 0; i < m_rows * m_cols; i++) { + m_buff[i].c = ' '; + m_buff[i].color = m_color; + } + if (m_mapped) redraw(); +} + +void SimpleVT::map(s32int row, s32int col) { + m_maprow = (row == -1 ? (Disp::textRows() / 2) - (m_rows / 2) : row); + m_mapcol = (col == -1 ? (Disp::textCols() / 2) - (m_cols / 2) : col); + m_mapped = true; + redraw(); + VT::map(this); +} + +void SimpleVT::unmap() { + m_mapped = false; + VT::unmap(this); +} + +void SimpleVT::redraw() { + if (!m_mapped) return; + for (u32int r = 0; r < m_rows; r++) { + for (u32int c = 0; c < m_cols; c++) { + Disp::putChar(r + m_maprow, c + m_mapcol, BUFCHR(r, c).c, BUFCHR(r, c).color); + } + } +} + +void SimpleVT::scroll() { + for (u32int l = 0; l < m_rows - 1; l++) { + for (u32int c = 0; c < m_cols; c++) { + BUFCHR(l, c) = BUFCHR(l + 1, c); + } + } + for (u32int c = 0; c < m_cols; c++) { + BUFCHR(m_rows - 1, c).c = ' '; + BUFCHR(m_rows - 1, c).color = m_color; + } + if (m_mapped) redraw(); +} + +void SimpleVT::updateCursor() { + Disp::moveCursor(m_csrlin + m_maprow, m_csrcol + m_mapcol); +} + +void SimpleVT::moveCursor(u32int row, u32int col) { + m_csrlin = row; + m_csrcol = col; + updateCursor(); +} + +void SimpleVT::setCursorLine(u32int line) { + m_csrlin = line; + updateCursor(); +} + +void SimpleVT::setCursorCol(u32int col) { + m_csrcol = col; + updateCursor(); +} + + +// Display functionn +void SimpleVT::put(WChar c, bool updatecsr) { + if (c.value == '\b') { + if (m_csrcol > 0) m_csrcol--; + putChar(m_csrlin, m_csrcol, ' '); + } else if (c.value == '\t') { + m_csrcol = (m_csrcol + 8) &~(8 - 1); + } else if (c.value == '\r') { + m_csrcol = 0; + } else if (c.value == '\n') { + m_csrcol = 0; + m_csrlin++; + } else if (c.value >= ' ') { //Printable character + putChar(m_csrlin, m_csrcol, c); + m_csrcol++; + } + if (m_csrcol >= m_cols) { + m_csrcol = 0; + m_csrlin++; + } + while (m_csrlin >= m_rows) { + scroll(); + m_csrlin--; + } + if (updatecsr) updateCursor(); +} + +void SimpleVT::hexDump(u8int *ptr, u32int sz, bool addnl) { + if (m_cols < 76) return; //Not enough space + VirtualTerminal::hexDump(ptr, sz, (m_cols == 76)); +} diff --git a/Source/Kernel/VTManager/SimpleVT.class.h b/Source/Kernel/VTManager/SimpleVT.class.h new file mode 100644 index 0000000..6a50549 --- /dev/null +++ b/Source/Kernel/VTManager/SimpleVT.class.h @@ -0,0 +1,42 @@ +#ifndef DEF_SIMPLEVT_CLASS_H +#define DEF_SIMPLEVT_CLASS_H + +#include + +class SimpleVT : public VirtualTerminal { + protected: + vtchr* m_buff; + u32int m_rows, m_cols; + u8int m_color; + + u32int m_maprow, m_mapcol; + bool m_mapped; + + u32int m_csrlin, m_csrcol; + + public: + SimpleVT(u32int rows, u32int cols, u8int fgcolor = 7, u8int bgcolor = 0); + virtual ~SimpleVT(); + + virtual void putChar(u32int row, u32int col, WChar c); + void clear(); + void setColor(u8int fgcolor, u8int bgcolor = 0xFF); + bool isBoxed() { return true; } + + void map(s32int row = -1, s32int col = -1); + void unmap(); + virtual void redraw(); + virtual void scroll(); //Scrolls 1 line + + virtual void updateCursor(); + void moveCursor(u32int row, u32int col); + void setCursorLine(u32int line); + void setCursorCol(u32int col); + + void put(WChar c, bool updatecsr = true); + + virtual void hexDump(u8int* ptr, u32int sz, bool addnl = false); //Ignore parameter addnl +}; + +#endif + diff --git a/Source/Kernel/VTManager/VT.ns.cpp b/Source/Kernel/VTManager/VT.ns.cpp index 76aeb47..87586bc 100644 --- a/Source/Kernel/VTManager/VT.ns.cpp +++ b/Source/Kernel/VTManager/VT.ns.cpp @@ -4,14 +4,14 @@ namespace VT { -Vector mappedVTs; +Vector mappedVTs; -void map(VirtualTerminal* vt) { +void map(SimpleVT* vt) { unmap(vt); //Bad things might happen mappedVTs.push(vt); } -void unmap(VirtualTerminal* vt) { +void unmap(SimpleVT* vt) { for (u32int i = 0; i < mappedVTs.size(); i++) { if (mappedVTs[i] == vt) { mappedVTs[i] = mappedVTs.back(); diff --git a/Source/Kernel/VTManager/VT.ns.h b/Source/Kernel/VTManager/VT.ns.h index 9e6d3ba..55556b9 100644 --- a/Source/Kernel/VTManager/VT.ns.h +++ b/Source/Kernel/VTManager/VT.ns.h @@ -2,12 +2,12 @@ #define DEF_VT_NS_H #include -#include +#include namespace VT { //These should be called only from inside class VirtualTerminal - void map(VirtualTerminal* vt); - void unmap(VirtualTerminal* vt); + void map(SimpleVT* vt); + void unmap(SimpleVT* vt); void redrawScreen(); } diff --git a/Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp b/Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp deleted file mode 100644 index 7c784fe..0000000 --- a/Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "VirtualTerminal.class.h" -#include - -using namespace Kbd; - -void VirtualTerminal::keyPress(keypress_t kp) { - m_kbdbuffMutex.waitLock(); - m_kbdbuff.push(kp); - if (!m_kbdMutex.locked()) { - if (kp.haschar && !kp.hascmd) { - put(kp.character); - } else if (kp.hascmd && !kp.haschar && kp.command == KBDC_ENTER) { - put("\n"); - } else if (kp.hascmd && !kp.haschar && kp.command == KBDC_TAB) { - put("\t"); - } else if (kp.hascmd && !kp.haschar && kp.command == KBDC_BACKSPACE) { - put("\b"); - } - } - m_kbdbuffMutex.unlock(); -} - -keypress_t VirtualTerminal::getKeypress(bool show, bool block) { - m_kbdMutex.waitLock(); - - if (m_kbdbuff.empty() && !block) { - m_kbdMutex.unlock(); - return keypress_t(); - } - - while (m_kbdbuff.empty()) - Task::currentThread->sleep(10); - - m_kbdbuffMutex.waitLock(); - keypress_t ret = m_kbdbuff[0]; - - for (u32int i = 1; i < m_kbdbuff.size(); i++) { - m_kbdbuff[i - 1] = m_kbdbuff[i]; - } - m_kbdbuff.pop(); - m_kbdbuffMutex.unlock(); - - if (show) { - if (ret.haschar && !ret.hascmd) { - put(ret.character); - } else if (ret.hascmd && !ret.haschar && ret.command == KBDC_ENTER) { - put("\n"); - } else if (ret.hascmd && !ret.haschar && ret.command == KBDC_TAB) { - put("\t"); - } else if (ret.hascmd && !ret.haschar && ret.command == KBDC_BACKSPACE) { - put("\b"); - } - } - - m_kbdMutex.unlock(); - return ret; -} - -String VirtualTerminal::readLine(bool show) { - String ret = ""; - keypress_t tmp = getKeypress(show); - while (!(tmp.hascmd && !tmp.haschar && tmp.command == KBDC_ENTER)) { - if (tmp.hascmd && !tmp.haschar && tmp.command == KBDC_BACKSPACE) { - if (!ret.empty()) ret = ret.substr(0, ret.size() - 1); - else put(" "); //Put a space so that cursor stays at same place - } else if (tmp.haschar && !tmp.hascmd) { - ret += tmp.character; - } - tmp = getKeypress(show); - } - if (!show) put("\n"); //Put a return if it hasn't been shown on getChar(); - return ret; -} diff --git a/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp new file mode 100644 index 0000000..1797554 --- /dev/null +++ b/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp @@ -0,0 +1,73 @@ +#include "VirtualTerminal.proto.h" +#include + +using namespace Kbd; + +void VirtualTerminal::keyPress(keypress_t kp) { + m_kbdbuffMutex.waitLock(); + m_kbdbuff.push(kp); + if (!m_kbdMutex.locked()) { + if (kp.haschar && !kp.hascmd) { + put(kp.character); + } else if (kp.hascmd && !kp.haschar && kp.command == KBDC_ENTER) { + put("\n"); + } else if (kp.hascmd && !kp.haschar && kp.command == KBDC_TAB) { + put("\t"); + } else if (kp.hascmd && !kp.haschar && kp.command == KBDC_BACKSPACE) { + put("\b"); + } + } + m_kbdbuffMutex.unlock(); +} + +keypress_t VirtualTerminal::getKeypress(bool show, bool block) { + m_kbdMutex.waitLock(); + + if (m_kbdbuff.empty() && !block) { + m_kbdMutex.unlock(); + return keypress_t(); + } + + while (m_kbdbuff.empty()) + Task::currentThread->sleep(10); + + m_kbdbuffMutex.waitLock(); + keypress_t ret = m_kbdbuff[0]; + + for (u32int i = 1; i < m_kbdbuff.size(); i++) { + m_kbdbuff[i - 1] = m_kbdbuff[i]; + } + m_kbdbuff.pop(); + m_kbdbuffMutex.unlock(); + + if (show) { + if (ret.haschar && !ret.hascmd) { + put(ret.character); + } else if (ret.hascmd && !ret.haschar && ret.command == KBDC_ENTER) { + put("\n"); + } else if (ret.hascmd && !ret.haschar && ret.command == KBDC_TAB) { + put("\t"); + } else if (ret.hascmd && !ret.haschar && ret.command == KBDC_BACKSPACE) { + put("\b"); + } + } + + m_kbdMutex.unlock(); + return ret; +} + +String VirtualTerminal::readLine(bool show) { + String ret = ""; + keypress_t tmp = getKeypress(show); + while (!(tmp.hascmd && !tmp.haschar && tmp.command == KBDC_ENTER)) { + if (tmp.hascmd && !tmp.haschar && tmp.command == KBDC_BACKSPACE) { + if (!ret.empty()) ret = ret.substr(0, ret.size() - 1); + else put(" "); //Put a space so that cursor stays at same place + } else if (tmp.haschar && !tmp.hascmd) { + ret += tmp.character; + } + tmp = getKeypress(show); + } + if (!show) put("\n"); //Put a return if it hasn't been shown on getChar(); + return ret; +} diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.cpp b/Source/Kernel/VTManager/VirtualTerminal.class.cpp deleted file mode 100644 index 7ee360b..0000000 --- a/Source/Kernel/VTManager/VirtualTerminal.class.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include "VirtualTerminal.class.h" -#include -#include - -#define BUFCHR(l, c) m_buff[((l) * m_cols) + (c)] - -VirtualTerminal::VirtualTerminal(u32int rows, u32int cols, u8int fgcolor, u8int bgcolor) : m_kbdMutex(false) { - m_buff = new chr[rows * cols]; - m_rows = rows; - m_cols = cols; - m_mapped = false; - setColor(fgcolor, bgcolor); - clear(); - - m_csrcol = 0; - m_csrlin = 0; -} - -VirtualTerminal::~VirtualTerminal() { - if (m_mapped) VT::unmap(this); - delete [] m_buff; -} - -void VirtualTerminal::setColor(u8int fgcolor, u8int bgcolor) { - if (bgcolor == 0xFF) { - m_color = (m_color & 0xF0) | fgcolor; - } else { - m_color = (bgcolor << 4) | fgcolor; - } -} - -void VirtualTerminal::putChar(u32int row, u32int col, WChar c) { - if (row >= m_rows or col >= m_cols) return; - chr* ch = &BUFCHR(row, col); - ch->c = c; - ch->color = m_color; - if (m_mapped) - Disp::putChar(row + m_maprow, col + m_mapcol, BUFCHR(row, col).c, m_color); -} - -void VirtualTerminal::clear() { - for (u32int i = 0; i < m_rows * m_cols; i++) { - m_buff[i].c = ' '; - m_buff[i].color = m_color; - } - if (m_mapped) redraw(); -} - -void VirtualTerminal::map(s32int row, s32int col) { - m_maprow = (row == -1 ? (Disp::textRows() / 2) - (m_rows / 2) : row); - m_mapcol = (col == -1 ? (Disp::textCols() / 2) - (m_cols / 2) : col); - m_mapped = true; - redraw(); - VT::map(this); -} - -void VirtualTerminal::unmap() { - m_mapped = false; - VT::unmap(this); -} - -void VirtualTerminal::redraw() { - if (!m_mapped) return; - for (u32int r = 0; r < m_rows; r++) { - for (u32int c = 0; c < m_cols; c++) { - Disp::putChar(r + m_maprow, c + m_mapcol, BUFCHR(r, c).c, BUFCHR(r, c).color); - } - } -} - -void VirtualTerminal::scroll() { - for (u32int l = 0; l < m_rows - 1; l++) { - for (u32int c = 0; c < m_cols; c++) { - BUFCHR(l, c) = BUFCHR(l + 1, c); - } - } - for (u32int c = 0; c < m_cols; c++) { - BUFCHR(m_rows - 1, c).c = ' '; - BUFCHR(m_rows - 1, c).color = m_color; - } - if (m_mapped) redraw(); -} - -void VirtualTerminal::updateCursor() { - Disp::moveCursor(m_csrlin + m_maprow, m_csrcol + m_mapcol); -} - -void VirtualTerminal::moveCursor(u32int row, u32int col) { - m_csrlin = row; - m_csrcol = col; - updateCursor(); -} - -void VirtualTerminal::setCursorLine(u32int line) { - m_csrlin = line; - updateCursor(); -} - -void VirtualTerminal::setCursorCol(u32int col) { - m_csrcol = col; - updateCursor(); -} - - -// Display functionn -void VirtualTerminal::put(WChar c, bool updatecsr) { - if (c.value == '\b') { - if (m_csrcol > 0) m_csrcol--; - putChar(m_csrlin, m_csrcol, ' '); - } else if (c.value == '\t') { - m_csrcol = (m_csrcol + 8) &~(8 - 1); - } else if (c.value == '\r') { - m_csrcol = 0; - } else if (c.value == '\n') { - m_csrcol = 0; - m_csrlin++; - } else if (c.value >= ' ') { //Printable character - putChar(m_csrlin, m_csrcol, c); - m_csrcol++; - } - if (m_csrcol >= m_cols) { - m_csrcol = 0; - m_csrlin++; - } - while (m_csrlin >= m_rows) { - scroll(); - m_csrlin--; - } - if (updatecsr) updateCursor(); -} - -void VirtualTerminal::write(const String& s, bool updatecsr) { - for (u32int i = 0; i < s.size(); i++) { - put(s[i], false); - } - if (updatecsr) updateCursor(); -} - -void VirtualTerminal::writeDec(s64int num, bool updatecsr) { - u64int i = num; - if (i == 0) { - put('0', false); - } else if (num < 0) { - put('-', false); - i = 0 - num; - } - char c[32]; - int n = 0; - while (i > 0) { - c[n] = '0' + (i % 10); - i /= 10; - n++; - } - while (n > 0) { - n--; - put(c[n], false); - } - if (updatecsr) updateCursor(); -} - -void VirtualTerminal::writeHex(u32int i, bool updatecsr) { - write("0x", false); - char hexdigits[] = "0123456789ABCDEF"; - for (u32int j = 0; j < 8; j++) { - put(hexdigits[(i & 0xF0000000) >> 28], false); - i = i << 4; - } - if (updatecsr) updateCursor(); -} - -void VirtualTerminal::hexDump(u8int *ptr, u32int sz) { - if (m_cols < 76) return; //Not enough space - write("HEX Dump, from "); writeHex((u32int)ptr); write("\n"); - char hexdigits[] = "0123456789ABCDEF"; - for (u32int i = 0; i < sz; i += 16) { - writeHex(i); - write(" "); - for (u32int j = 0; j < 16; j++) { - u8int b = ptr[i + j]; - if (j > 7) put(" "); - put(hexdigits[b >> 4]); - put(hexdigits[b & 0xF]); - if (j < 8) put(" "); - } - write(" "); - for (u32int j = 0; j < 16; j++) { - u8int b = ptr[i + j]; - if (b >= 0x20 && b < 128) { - put(WChar(b)); - } else { - put("."); - } - } - if (m_cols > 76) write("\n"); - } -} diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.h b/Source/Kernel/VTManager/VirtualTerminal.class.h deleted file mode 100644 index d8d7104..0000000 --- a/Source/Kernel/VTManager/VirtualTerminal.class.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef DEF_VIRTUALTERMINAL_CLASS_H -#define DEF_VIRTUALTERMINAL_CLASS_H - -#include -#include -#include -#include -#include - -struct chr { - u8int color; - WChar c; -}; - -class VirtualTerminal { - private: - chr* m_buff; - u32int m_rows, m_cols; - u8int m_color; - - u32int m_maprow, m_mapcol; - bool m_mapped; - - u32int m_csrlin, m_csrcol; - - Mutex m_kbdMutex, m_kbdbuffMutex; - Vector m_kbdbuff; //Key press events buffer - - public: - VirtualTerminal(u32int rows, u32int cols, u8int fgcolor = 7, u8int bgcolor = 0); - ~VirtualTerminal(); - - void setColor(u8int fgcolor, u8int bgcolor = 0xFF); - void putChar(u32int row, u32int col, WChar c); - void clear(); - - void map(s32int row = -1, s32int col = -1); - void unmap(); - void redraw(); - void scroll(); //Scrolls 1 line - - void updateCursor(); - void moveCursor(u32int row, u32int col); - void setCursorLine(u32int line); - void setCursorCol(u32int col); - - //Display functions - void put(WChar c, bool updatecsr = true); - void write(const String& s, bool updatecsr = true); - void writeDec(s64int num, bool updatecsr = true); - void writeHex(u32int i, bool updatecsr = true); - - void hexDump(u8int* ptr, u32int sz); - - inline VirtualTerminal& operator<<(const String& s) { write(s); return *this; } - //inline VirtualTerminal& operator<<(WChar c) { put(c); return *this; } - inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; } - inline VirtualTerminal& operator<<(s64int i) { writeDec(i); return *this; } - inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; } - - //Keyboard functions - void keyPress(Kbd::keypress_t kp); //Called by Kbd:: when a key is pressed - Kbd::keypress_t getKeypress(bool show = true, bool block = true); //Block : must we wait for a key to be pressed ? - String readLine(bool show = true); -}; - -#endif diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp new file mode 100644 index 0000000..7a9ffa8 --- /dev/null +++ b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp @@ -0,0 +1,74 @@ +#include "VirtualTerminal.proto.h" +#include +#include + +VirtualTerminal::VirtualTerminal() : m_kbdMutex(false), m_kbdbuffMutex(false) { +} + +VirtualTerminal::~VirtualTerminal() { +} + +void VirtualTerminal::write(const String& s, bool updatecsr) { + for (u32int i = 0; i < s.size(); i++) { + put(s[i], false); + } + if (updatecsr) updateCursor(); +} + +void VirtualTerminal::writeDec(s64int num, bool updatecsr) { + u64int i = num; + if (i == 0) { + put('0', false); + } else if (num < 0) { + put('-', false); + i = 0 - num; + } + char c[32]; + int n = 0; + while (i > 0) { + c[n] = '0' + (i % 10); + i /= 10; + n++; + } + while (n > 0) { + n--; + put(c[n], false); + } + if (updatecsr) updateCursor(); +} + +void VirtualTerminal::writeHex(u32int i, bool updatecsr) { + write("0x", false); + char hexdigits[] = "0123456789ABCDEF"; + for (u32int j = 0; j < 8; j++) { + put(hexdigits[(i & 0xF0000000) >> 28], false); + i = i << 4; + } + if (updatecsr) updateCursor(); +} + +void VirtualTerminal::hexDump(u8int *ptr, u32int sz, bool addnl) { + write("HEX Dump, from "); writeHex((u32int)ptr); write("\n"); + char hexdigits[] = "0123456789ABCDEF"; + for (u32int i = 0; i < sz; i += 16) { + writeHex(i); + write(" "); + for (u32int j = 0; j < 16; j++) { + u8int b = ptr[i + j]; + if (j > 7) put(" "); + put(hexdigits[b >> 4]); + put(hexdigits[b & 0xF]); + if (j < 8) put(" "); + } + write(" "); + for (u32int j = 0; j < 16; j++) { + u8int b = ptr[i + j]; + if (b >= 0x20 && b < 128) { + put(WChar(b)); + } else { + put("."); + } + } + if (addnl) write("\n"); + } +} diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.h b/Source/Kernel/VTManager/VirtualTerminal.proto.h new file mode 100644 index 0000000..bd38d89 --- /dev/null +++ b/Source/Kernel/VTManager/VirtualTerminal.proto.h @@ -0,0 +1,51 @@ +#ifndef DEF_VIRTUALTERMINAL_CLASS_H +#define DEF_VIRTUALTERMINAL_CLASS_H + +#include +#include +#include +#include +#include + +struct vtchr { + u8int color; + WChar c; +}; + +class VirtualTerminal { + protected: + Mutex m_kbdMutex, m_kbdbuffMutex; + Vector m_kbdbuff; //Key press events buffer + + public: + VirtualTerminal(); + virtual ~VirtualTerminal(); + + virtual void setColor(u8int fgcolor, u8int bgcolor = 0xFF) {} //For a pipe/file VT, this will do nothing. + virtual bool isBoxed() = 0; + + virtual void updateCursor() {} + virtual void moveCursor(u32int row, u32int col) {} //These are not implemented for pipe/file VTs + virtual void setCursorLine(u32int line) {} + virtual void setCursorCol(u32int col) {} //This one could be, and should be. It's used a lot for tabulating, etc. + + //Display functions + virtual void put(WChar c, bool updatecsr = true) = 0; + void write(const String& s, bool updatecsr = true); + void writeDec(s64int num, bool updatecsr = true); + void writeHex(u32int i, bool updatecsr = true); + + virtual void hexDump(u8int* ptr, u32int sz, bool addnl = true); //Always ignore parameter addnl + + inline VirtualTerminal& operator<<(const String& s) { write(s); return *this; } + inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; } + inline VirtualTerminal& operator<<(s64int i) { writeDec(i); return *this; } + inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; } + + //Keyboard functions + virtual void keyPress(Kbd::keypress_t kp); //Called by Kbd:: when a key is pressed, overloaded by ScrollableVT + Kbd::keypress_t getKeypress(bool show = true, bool block = true); //Block : must we wait for a key to be pressed ? + String readLine(bool show = true); +}; + +#endif -- cgit v1.2.3