From 7b0d6ac9f903296c7537cec9ac606d49cb364049 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 11 Sep 2009 16:22:30 +0200 Subject: Nothing, really --- Source/Kernel/Core/kmain.wtf.cpp | 3 +- Source/Kernel/DeviceManager/Disp.ns.cpp | 2 +- Source/Kernel/DeviceManager/Disp.ns.h | 4 +- Source/Kernel/DeviceManager/Kbd.ns.cpp | 19 +++-- Source/Kernel/DeviceManager/Kbd.ns.h | 6 +- Source/Kernel/Devices/Device.proto.h | 1 + Source/Kernel/Devices/Display/Display.proto.h | 5 +- .../Kernel/Devices/Display/VGATextOutput.class.cpp | 2 +- .../Kernel/Devices/Display/VGATextOutput.class.h | 2 +- Source/Kernel/Devices/Keyboard/Keyboard.proto.h | 1 + Source/Kernel/Library/String.class.cpp | 38 +++++----- Source/Kernel/Library/String.class.h | 12 ++-- Source/Kernel/Library/WChar.class.cpp | 80 +++++++++++++++++++++ Source/Kernel/Library/WChar.class.h | 51 +++++++++++++ Source/Kernel/Library/wchar.class.cpp | 80 --------------------- Source/Kernel/Library/wchar.class.h | 51 ------------- Source/Kernel/Makefile | 2 +- Source/Kernel/Melon.ke | Bin 112107 -> 118822 bytes Source/Kernel/MemoryManager/PageDirectory.class.h | 4 ++ Source/Kernel/Ressources/keymap-fr.wtf.c | 19 +++-- Source/Kernel/VFS/Partition.class.cpp | 4 +- Source/Kernel/VTManager/VirtualTerminal.class.cpp | 6 +- Source/Kernel/VTManager/VirtualTerminal.class.h | 8 +-- 23 files changed, 213 insertions(+), 187 deletions(-) create mode 100644 Source/Kernel/Library/WChar.class.cpp create mode 100644 Source/Kernel/Library/WChar.class.h delete mode 100644 Source/Kernel/Library/wchar.class.cpp delete mode 100644 Source/Kernel/Library/wchar.class.h (limited to 'Source') diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp index cac2da9..8188e91 100644 --- a/Source/Kernel/Core/kmain.wtf.cpp +++ b/Source/Kernel/Core/kmain.wtf.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -101,7 +100,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) { PROCESSING(kvt, "Setting up keyboard..."); Dev::registerDevice(new PS2Keyboard()); //Initialize keyboard driver - Kbd::setKeymap(keymapFR_normal, keymapFR_shift, keymapFR_altgr, keymapFR_shiftaltgr); //Load keymap + Kbd::setKeymap(keymapFR_normal, keymapFR_shift, keymapFR_caps, keymapFR_altgr, keymapFR_shiftaltgr); //Load keymap Kbd::setFocus(kvt); //Set focus to virtual terminal OK(kvt); diff --git a/Source/Kernel/DeviceManager/Disp.ns.cpp b/Source/Kernel/DeviceManager/Disp.ns.cpp index a59b27c..4be8d03 100644 --- a/Source/Kernel/DeviceManager/Disp.ns.cpp +++ b/Source/Kernel/DeviceManager/Disp.ns.cpp @@ -12,7 +12,7 @@ u16int textRows() { return mode.textRows; } -void putChar(u16int line, u16int col, wchar c, u8int color) { +void putChar(u16int line, u16int col, WChar c, u8int color) { if (line >= mode.textRows or col >= mode.textCols) return; mode.device->putChar(line, col, c, color); } diff --git a/Source/Kernel/DeviceManager/Disp.ns.h b/Source/Kernel/DeviceManager/Disp.ns.h index e6c378b..5a92e69 100644 --- a/Source/Kernel/DeviceManager/Disp.ns.h +++ b/Source/Kernel/DeviceManager/Disp.ns.h @@ -2,7 +2,7 @@ #define DEF_DISP_NS_H #include -#include +#include namespace Disp { struct mode_t { @@ -12,7 +12,7 @@ namespace Disp { u16int textCols(); u16int textRows(); - void putChar(u16int line, u16int col, wchar c, u8int color); + void putChar(u16int line, u16int col, WChar c, u8int color); void moveCursor(u16int line, u16int col); void clear(); diff --git a/Source/Kernel/DeviceManager/Kbd.ns.cpp b/Source/Kernel/DeviceManager/Kbd.ns.cpp index 135d521..95a97e3 100644 --- a/Source/Kernel/DeviceManager/Kbd.ns.cpp +++ b/Source/Kernel/DeviceManager/Kbd.ns.cpp @@ -26,7 +26,7 @@ u8int ctrlkeys[] = { /* 0xF0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -wchar *keymapNormal = NULL, *keymapShift = NULL, *keymapAltgr = NULL, *keymapShiftAltgr = NULL; +WChar *keymapNormal = NULL, *keymapShift = NULL, *keymapCaps = NULL, *keymapAltgr = NULL, *keymapShiftAltgr = NULL; u8int kbdstatus = 0; VirtualTerminal *focusedVT = NULL; //This is the VT that must receive the character @@ -58,9 +58,10 @@ void setFocus(VirtualTerminal* vt) { focusedVT = vt; } -void setKeymap(wchar* kmNormal, wchar* kmShift, wchar* kmAltgr, wchar* kmShiftAltgr) { +void setKeymap(WChar* kmNormal, WChar* kmShift, WChar* kmCaps, WChar* kmAltgr, WChar* kmShiftAltgr) { keymapNormal = kmNormal; keymapShift = kmShift; + keymapCaps = kmCaps; keymapAltgr = kmAltgr; keymapShiftAltgr = kmShiftAltgr; } @@ -85,11 +86,14 @@ void keyPress(u8int scancode) { if ((kbdstatus & STATUS_ALT) or (kbdstatus & STATUS_CTRL)) { kp.hascmd = true; } - if ((kbdstatus & STATUS_SHIFT) xor (kbdstatus & STATUS_CAPS)) { + if (((kbdstatus & STATUS_SHIFT) != 0) xor ((kbdstatus & STATUS_CAPS) != 0)) { if (kbdstatus & STATUS_ALTGR) { if (keymapShiftAltgr != NULL) kp.character = keymapShiftAltgr[scancode]; } else { - if (keymapShift != NULL) kp.character = keymapShift[scancode]; + if (keymapCaps != NULL and (kbdstatus & STATUS_CAPS)) + kp.character = keymapCaps[scancode]; + else if (keymapShift != NULL) + kp.character = keymapShift[scancode]; } } else { if (kbdstatus & STATUS_ALTGR) { @@ -152,11 +156,14 @@ void keyRelease(u8int scancode) { if ((kbdstatus & STATUS_ALT) or (kbdstatus & STATUS_CTRL)) { kp.hascmd = true; } - if ((kbdstatus & STATUS_SHIFT) xor (kbdstatus & STATUS_CAPS)) { + if (((kbdstatus & STATUS_SHIFT) != 0) xor ((kbdstatus & STATUS_CAPS) != 0)) { if (kbdstatus & STATUS_ALTGR) { if (keymapShiftAltgr != NULL) kp.character = keymapShiftAltgr[scancode]; } else { - if (keymapShift != NULL) kp.character = keymapShift[scancode]; + if (keymapCaps != NULL and (kbdstatus & STATUS_CAPS)) + kp.character = keymapCaps[scancode]; + else if (keymapShift != NULL) + kp.character = keymapShift[scancode]; } } else { if (kbdstatus & STATUS_ALTGR) { diff --git a/Source/Kernel/DeviceManager/Kbd.ns.h b/Source/Kernel/DeviceManager/Kbd.ns.h index efd7a48..34ad0e4 100644 --- a/Source/Kernel/DeviceManager/Kbd.ns.h +++ b/Source/Kernel/DeviceManager/Kbd.ns.h @@ -2,7 +2,7 @@ #define DEF_KBD_NS_H #include -#include +#include //Used by variable kbdstatus #define STATUS_SCRL 0x40 @@ -87,12 +87,12 @@ namespace Kbd { bool haschar; u8int modifiers; u8int command; - wchar character; //is 0 if !haschar + WChar character; //is 0 if !haschar keypress_t() : hascmd(false), haschar(false), command(0), character('\0') {}; }; void setFocus(VirtualTerminal* vt); - void setKeymap(wchar* kmNormal, wchar* kmShift, wchar* kmAltgr, wchar* kmShiftAltgr = NULL); + void setKeymap(WChar* kmNormal, WChar* kmShift, WChar* kmCaps, WChar* kmAltgr, WChar* kmShiftAltgr = NULL); void updateLeds(); void keyPress(u8int scancode); void keyRelease(u8int scancode); diff --git a/Source/Kernel/Devices/Device.proto.h b/Source/Kernel/Devices/Device.proto.h index d5d6422..4f216ec 100644 --- a/Source/Kernel/Devices/Device.proto.h +++ b/Source/Kernel/Devices/Device.proto.h @@ -7,6 +7,7 @@ class Device { public: + virtual ~Device() {}; virtual String getClass() = 0; virtual String getName() = 0; diff --git a/Source/Kernel/Devices/Display/Display.proto.h b/Source/Kernel/Devices/Display/Display.proto.h index f2a98af..d4bd8fc 100644 --- a/Source/Kernel/Devices/Display/Display.proto.h +++ b/Source/Kernel/Devices/Display/Display.proto.h @@ -3,13 +3,14 @@ #include #include -#include +#include class Display : public Device { public: + virtual ~Display() {} virtual u16int textCols() = 0; virtual u16int textRows() = 0; - virtual void putChar(u16int line, u16int col, wchar c, u8int color) = 0; //Color : + virtual void putChar(u16int line, u16int col, WChar c, u8int color) = 0; //Color : virtual void moveCursor(u16int line, u16int col) = 0; virtual void clear() = 0; }; diff --git a/Source/Kernel/Devices/Display/VGATextOutput.class.cpp b/Source/Kernel/Devices/Display/VGATextOutput.class.cpp index 2a69754..aca5ce6 100644 --- a/Source/Kernel/Devices/Display/VGATextOutput.class.cpp +++ b/Source/Kernel/Devices/Display/VGATextOutput.class.cpp @@ -21,7 +21,7 @@ u16int VGATextOutput::textRows() { return 25; } -void VGATextOutput::putChar(u16int line, u16int col, wchar c, u8int color) { +void VGATextOutput::putChar(u16int line, u16int col, WChar c, u8int color) { u16int* where = (u16int*)RAM_ADDR; where[(80 * line) + col] = (color << 8) | c.toAscii(); } diff --git a/Source/Kernel/Devices/Display/VGATextOutput.class.h b/Source/Kernel/Devices/Display/VGATextOutput.class.h index 7746a7b..864ae35 100644 --- a/Source/Kernel/Devices/Display/VGATextOutput.class.h +++ b/Source/Kernel/Devices/Display/VGATextOutput.class.h @@ -10,7 +10,7 @@ class VGATextOutput : public Display { u16int textCols(); u16int textRows(); - void putChar(u16int line, u16int col, wchar c, u8int color); + void putChar(u16int line, u16int col, WChar c, u8int color); void moveCursor(u16int line, u16int col); void clear(); }; diff --git a/Source/Kernel/Devices/Keyboard/Keyboard.proto.h b/Source/Kernel/Devices/Keyboard/Keyboard.proto.h index d6898f8..f9f716c 100644 --- a/Source/Kernel/Devices/Keyboard/Keyboard.proto.h +++ b/Source/Kernel/Devices/Keyboard/Keyboard.proto.h @@ -5,6 +5,7 @@ class Keyboard : public Device { public: + virtual ~Keyboard() {} virtual void updateLeds(u32int kbdstatus) = 0; }; diff --git a/Source/Kernel/Library/String.class.cpp b/Source/Kernel/Library/String.class.cpp index 518d8c9..e70d19f 100644 --- a/Source/Kernel/Library/String.class.cpp +++ b/Source/Kernel/Library/String.class.cpp @@ -6,7 +6,7 @@ using namespace CMem; //strlen and memcpy String String::hex(u32int number) { String ret; ret.m_length = 10; - ret.m_string = new wchar[11]; + ret.m_string = new WChar[11]; ret.m_string[0] = '0'; ret.m_string[1] = 'x'; ret.m_string[10] = 0; @@ -35,7 +35,7 @@ String String::number(s32int number) { String ret; ret.m_length = order; - ret.m_string = new wchar[order + 1]; + ret.m_string = new WChar[order + 1]; for (u32int i = order; i > 0; i--) { ret.m_string[i - 1] = numbers[number % 10]; @@ -55,12 +55,12 @@ String::String() { } String::String(char* string) { - m_length = wchar::utf8len(string); + m_length = WChar::utf8len(string); if (m_length == 0) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; int i = 0, l = strlen(string), c = 0; while (i < l) { i += m_string[c].affectUtf8(string + i); @@ -75,7 +75,7 @@ String::String(const String &other) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; for (u32int i = 0; i < m_length; i++) { m_string[i] = other.m_string[i]; } @@ -93,7 +93,7 @@ void String::operator= (const String &other) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; for (u32int i = 0; i < m_length; i++) { m_string[i] = other.m_string[i]; } @@ -101,13 +101,13 @@ void String::operator= (const String &other) { } void String::operator= (char* string) { - m_length = wchar::utf8len(string); + m_length = WChar::utf8len(string); if (m_string != 0) delete [] m_string; if (m_length == 0) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; int i = 0, l = strlen(string), c = 0; while (i < l) { i += m_string[c].affectUtf8(string + i); @@ -125,9 +125,9 @@ bool String::operator== (String &other) { } bool String::operator== (char* string) { - if (m_length != wchar::utf8len(string)) return false; + if (m_length != WChar::utf8len(string)) return false; int i = 0, l = strlen(string), c = 0; - wchar tmp; + WChar tmp; while (i < l) { i += tmp.affectUtf8(string + i); if (m_string[c] != tmp) return false; @@ -137,7 +137,7 @@ bool String::operator== (char* string) { } String& String::operator+= (String &other) { - wchar* newdata = new wchar[m_length + other.m_length + 1]; + WChar* newdata = new WChar[m_length + other.m_length + 1]; for (u32int i = 0; i < m_length; i++) { newdata[i] = m_string[i]; } @@ -152,7 +152,7 @@ String& String::operator+= (String &other) { } String& String::operator+= (char* other) { - wchar* newdata = new wchar[m_length + wchar::utf8len(other) + 1]; + WChar* newdata = new WChar[m_length + WChar::utf8len(other) + 1]; for (u32int i = 0; i < m_length; i++) { newdata[i] = m_string[i]; } @@ -168,8 +168,8 @@ String& String::operator+= (char* other) { return *this; } -String& String::operator+= (wchar other) { - wchar* newdata = new wchar[m_length + 2]; +String& String::operator+= (WChar other) { + WChar* newdata = new WChar[m_length + 2]; for (u32int i = 0; i < m_length; i++) { newdata[i] = m_string[i]; } @@ -191,7 +191,7 @@ String& String::operator+ (char* other) { //Can be optimized return (ret += other); } -String& String::operator+ (wchar other) { +String& String::operator+ (WChar other) { String ret(*this); return (ret += other); } @@ -236,7 +236,7 @@ u32int String::toInt16() { return number; } -wchar& String::operator[] (int index) { +WChar& String::operator[] (int index) { return m_string[index]; } @@ -254,7 +254,7 @@ bool String::empty() { return (m_length == 0); } -Vector String::split(wchar c) { +Vector String::split(WChar c) { Vector ret; ret.push(String("")); for (u32int i = 0; i < m_length; i++) { @@ -274,9 +274,9 @@ String String::substr(s32int start, s32int size) { size = 0 - size; } String ret; - ret.m_string = new wchar[size + 1]; + ret.m_string = new WChar[size + 1]; ret.m_length = size; - memcpy((u8int*)ret.m_string, (const u8int*)(m_string + start), size * sizeof(wchar)); + memcpy((u8int*)ret.m_string, (const u8int*)(m_string + start), size * sizeof(WChar)); ret.m_string[size] = 0; return ret; } diff --git a/Source/Kernel/Library/String.class.h b/Source/Kernel/Library/String.class.h index d086b31..ecbc2a0 100644 --- a/Source/Kernel/Library/String.class.h +++ b/Source/Kernel/Library/String.class.h @@ -2,13 +2,13 @@ #define DEF_STRING_CLASS #include -#include +#include template class Vector; class String { private: - wchar *m_string; + WChar *m_string; u32int m_length; public: @@ -27,19 +27,19 @@ class String { bool operator== (char* string); String &operator+= (String &other); String &operator+= (char* other); - String &operator+= (wchar other); + String &operator+= (WChar other); String &operator+ (String &other); String &operator+ (char* other); - String &operator+ (wchar other); + String &operator+ (WChar other); s32int toInt(); u32int toInt16(); //From HEX - wchar& operator[] (int index); + WChar& operator[] (int index); u32int size(); void clear(); bool empty(); - Vector split(wchar c); + Vector split(WChar c); String substr(s32int start, s32int size); }; diff --git a/Source/Kernel/Library/WChar.class.cpp b/Source/Kernel/Library/WChar.class.cpp new file mode 100644 index 0000000..c1a1977 --- /dev/null +++ b/Source/Kernel/Library/WChar.class.cpp @@ -0,0 +1,80 @@ +#include "WChar.class.h" + +WChar WChar::CP437[] = { //These are the UTF8 equivalents for the 128 extra characters of code page 850 + "Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", + "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "¢", "£", "¥", "₧", "ƒ", + "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»", + "░", "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐", + "└", "┴", "┬", "├", "─", "┼", "╞", "╟", "╚", "╔", "╩", "╦", "╠", "═", "╬", "¤", + "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐", "▀", + "α", "ß", "Γ", "π", "Σ", "σ", "µ", "τ", "Φ", "Θ", "Ω", "δ", "∞", "φ", "ε", "∩", + "≡", "±", "≥", "≤", "⌠", "⌡", "÷", "≈", "°", "∙", "·", "√", "ⁿ", "²", "■", "⍽" +}; + +WChar::WChar() { + value = 0; +} + +WChar::WChar(char c) { + affectAscii(c); +} + +WChar::WChar(char* c) { + affectUtf8(c); +} + +u32int WChar::utf8len(char* c) { + int i = 0, l = CMem::strlen(c), co = 0; + while (i < l) { + if ((c[i] & 0x80) == 0) i += 1; + else if ((c[i] & 0xE0) == 0xC0) i += 2; + else if ((c[i] & 0xF0) == 0xE0) i += 3; + else if ((c[i] & 0xF8) == 0xF0) i += 4; + else i += 1; + co++; + } + return co; +} + +void WChar::affectAscii(char c) { + if (c >= 0) value = c; + else value = CP437[c + 128]; +} + +u32int WChar::affectUtf8(char* c) { //Returns the number of bytes for the character + /*if ((c[0] & 0xB0) == 0x80) { //11000000b == 10000000b, means we are IN a sequence + value = 0; + return 1; + }*/ + if ((c[0] & 0x80) == 0) { + value = c[0]; //0x80 = 10000000b + return 1; + } + if ((c[0] & 0xE0) == 0xC0) { // 11100000b, 11000000b + value = ((c[0] & 0x1F) << 6) | (c[1] & 0x3F); + if (value < 128) value = 0; //Bad value + return 2; + } + if ((c[0] & 0xF0) == 0xE0) { // 11110000b, 11100000b + value = ((c[0] & 0x0F) << 12) | ((c[1] & 0x3F) << 6) | (c[2] & 0x3F); + if (value < 2048) value = 0; //Bad value + if (value >= 0xD800 and value <= 0xDFFF) value = 0; //These values are unallowed + if (value >= 0xFFFE and value <= 0xFFFF) value = 0; + return 3; + } + if ((c[0] & 0xF8) == 0xF0) { // 11111000b, 11110000b + value = ((c[0] & 0x0E) << 18) | ((c[1] & 0x3F) << 12) | ((c[2] & 0x3F) << 6) | (c[3] & 0x3F); + if (value < 65536) value = 0; //Bad value + return 4; + } + value = 0; //Something wrong happenned + return 1; +} + +u8int WChar::toAscii() { + if (value < 128) return (char)value; + for (int i = 0; i < 128; i++) { + if (CP437[i] == value) return (i + 128); + } + return '?'; +} diff --git a/Source/Kernel/Library/WChar.class.h b/Source/Kernel/Library/WChar.class.h new file mode 100644 index 0000000..c582017 --- /dev/null +++ b/Source/Kernel/Library/WChar.class.h @@ -0,0 +1,51 @@ +#ifndef DEF_UCHAR_CLASS_H +#define DEF_UCHAR_CLASS_H + +#include + +struct WChar { + u32int value; + static WChar CP437[]; + + WChar(); //Creates a null character + WChar(char c); //From ascii character + WChar(char* c); //From utf8 string + + static u32int utf8len(char* c); //Returns count of utf8 characters in string + + void affectAscii(char c); + u32int affectUtf8(char* c); + void affectUtf16(char* c); + void affectUtf32(char* c); + u8int toAscii(); + + inline WChar operator+ (u32int other) { + WChar r; + r.value = value + other; + return r; + } + inline WChar operator- (u32int other) { + WChar r; + r.value = value - other; + return r; + } + inline WChar& operator+= (u32int other) { + value += other; + return *this; + } + inline WChar& operator-= (u32int other) { + value -= other; + return *this; + } + inline bool operator== (u32int other) { + return value == other; + } + inline u32int operator= (u32int v) { + value = v; + return v; + } + + inline operator u32int () { return value; } +}; + +#endif diff --git a/Source/Kernel/Library/wchar.class.cpp b/Source/Kernel/Library/wchar.class.cpp deleted file mode 100644 index 3a2ef92..0000000 --- a/Source/Kernel/Library/wchar.class.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "wchar.class.h" - -wchar wchar::CP437[] = { //These are the UTF8 equivalents for the 128 extra characters of code page 850 - "Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", - "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "¢", "£", "¥", "₧", "ƒ", - "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»", - "░", "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐", - "└", "┴", "┬", "├", "─", "┼", "╞", "╟", "╚", "╔", "╩", "╦", "╠", "═", "╬", "¤", - "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐", "▀", - "α", "ß", "Γ", "π", "Σ", "σ", "µ", "τ", "Φ", "Θ", "Ω", "δ", "∞", "φ", "ε", "∩", - "≡", "±", "≥", "≤", "⌠", "⌡", "÷", "≈", "°", "∙", "·", "√", "ⁿ", "²", "■", "⍽" -}; - -wchar::wchar() { - value = 0; -} - -wchar::wchar(char c) { - affectAscii(c); -} - -wchar::wchar(char* c) { - affectUtf8(c); -} - -u32int wchar::utf8len(char* c) { - int i = 0, l = CMem::strlen(c), co = 0; - while (i < l) { - if ((c[i] & 0x80) == 0) i += 1; - else if ((c[i] & 0xE0) == 0xC0) i += 2; - else if ((c[i] & 0xF0) == 0xE0) i += 3; - else if ((c[i] & 0xF8) == 0xF0) i += 4; - else i += 1; - co++; - } - return co; -} - -void wchar::affectAscii(char c) { - if (c >= 0) value = c; - else value = CP437[c + 128]; -} - -u32int wchar::affectUtf8(char* c) { //Returns the number of bytes for the character - /*if ((c[0] & 0xB0) == 0x80) { //11000000b == 10000000b, means we are IN a sequence - value = 0; - return 1; - }*/ - if ((c[0] & 0x80) == 0) { - value = c[0]; //0x80 = 10000000b - return 1; - } - if ((c[0] & 0xE0) == 0xC0) { // 11100000b, 11000000b - value = ((c[0] & 0x1F) << 6) | (c[1] & 0x3F); - if (value < 128) value = 0; //Bad value - return 2; - } - if ((c[0] & 0xF0) == 0xE0) { // 11110000b, 11100000b - value = ((c[0] & 0x0F) << 12) | ((c[1] & 0x3F) << 6) | (c[2] & 0x3F); - if (value < 2048) value = 0; //Bad value - if (value >= 0xD800 and value <= 0xDFFF) value = 0; //These values are unallowed - if (value >= 0xFFFE and value <= 0xFFFF) value = 0; - return 3; - } - if ((c[0] & 0xF8) == 0xF0) { // 11111000b, 11110000b - value = ((c[0] & 0x0E) << 18) | ((c[1] & 0x3F) << 12) | ((c[2] & 0x3F) << 6) | (c[3] & 0x3F); - if (value < 65536) value = 0; //Bad value - return 4; - } - value = 0; //Something wrong happenned - return 1; -} - -u8int wchar::toAscii() { - if (value < 128) return (char)value; - for (int i = 0; i < 128; i++) { - if (CP437[i] == value) return (i + 128); - } - return '?'; -} diff --git a/Source/Kernel/Library/wchar.class.h b/Source/Kernel/Library/wchar.class.h deleted file mode 100644 index cadabd0..0000000 --- a/Source/Kernel/Library/wchar.class.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef DEF_UCHAR_CLASS_H -#define DEF_UCHAR_CLASS_H - -#include - -struct wchar { - u32int value; - static wchar CP437[]; - - wchar(); //Creates a null character - wchar(char c); //From ascii character - wchar(char* c); //From utf8 string - - static u32int utf8len(char* c); //Returns count of utf8 characters in string - - void affectAscii(char c); - u32int affectUtf8(char* c); - void affectUtf16(char* c); - void affectUtf32(char* c); - u8int toAscii(); - - inline wchar operator+ (u32int other) { - wchar r; - r.value = value + other; - return r; - } - inline wchar operator- (u32int other) { - wchar r; - r.value = value - other; - return r; - } - inline wchar& operator+= (u32int other) { - value += other; - return *this; - } - inline wchar& operator-= (u32int other) { - value -= other; - return *this; - } - inline bool operator== (u32int other) { - return value == other; - } - inline u32int operator= (u32int v) { - value = v; - return v; - } - - inline operator u32int () { return value; } -}; - -#endif diff --git a/Source/Kernel/Makefile b/Source/Kernel/Makefile index 87f1594..e0f2068 100644 --- a/Source/Kernel/Makefile +++ b/Source/Kernel/Makefile @@ -35,7 +35,7 @@ Objects = Core/loader.wtf.o \ VTManager/VT.ns.o \ Library/Bitset.class.o \ Library/String.class.o \ - Library/wchar.class.o \ + Library/WChar.class.o \ VFS/Partition.class.o \ VFS/Part.ns.o \ SyscallManager/IDT.ns.o \ diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke index c643803..996e1b4 100755 Binary files a/Source/Kernel/Melon.ke and b/Source/Kernel/Melon.ke differ diff --git a/Source/Kernel/MemoryManager/PageDirectory.class.h b/Source/Kernel/MemoryManager/PageDirectory.class.h index 8dac7ce..e06b546 100644 --- a/Source/Kernel/MemoryManager/PageDirectory.class.h +++ b/Source/Kernel/MemoryManager/PageDirectory.class.h @@ -29,6 +29,10 @@ struct PageDirectory { void allocFrame(u32int address, bool is_user, bool is_writable); void freeFrame(u32int address); void switchTo(); + + private: + PageDirectory(const PageDirectory& other); + void operator=(const PageDirectory& other); }; diff --git a/Source/Kernel/Ressources/keymap-fr.wtf.c b/Source/Kernel/Ressources/keymap-fr.wtf.c index 0662b85..f24c14d 100644 --- a/Source/Kernel/Ressources/keymap-fr.wtf.c +++ b/Source/Kernel/Ressources/keymap-fr.wtf.c @@ -1,6 +1,6 @@ //This file is precious !!! Very precious !! -wchar keymapFR_normal[128] = { +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", @@ -11,7 +11,7 @@ wchar keymapFR_normal[128] = { /* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; -wchar keymapFR_shift[128] = { +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", @@ -22,7 +22,18 @@ wchar keymapFR_shift[128] = { /* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -wchar keymapFR_altgr[128] = { +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", "ĸ", "ł", "µ", "^", "¬", "", "`", "ł", "»", "¢", "“", @@ -33,7 +44,7 @@ wchar keymapFR_altgr[128] = { /* 0x70 */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -wchar keymapFR_shiftaltgr[128] = { +WChar keymapFR_shiftaltgr[128] = { /* 0x00 */ "", "", "¡", "⅛", "£", "$", "⅜", "⅝", "⅞", "™", "±", "°", "¿", "˛", "", "", /* 0x10 */ "Æ", "<", "¢", "®", "Ŧ", "¥", "↑", "ı", "Ø", "Þ", "°", "¯", "", "", "Ω", "§", /* 0x20 */ "Ð", "ª", "Ŋ", "Ħ", "J", "&", "Ł", "º", "ˇ", "¬", "", "˘", "Ł", ">", "©", "‘", diff --git a/Source/Kernel/VFS/Partition.class.cpp b/Source/Kernel/VFS/Partition.class.cpp index 1032dee..b62f33c 100644 --- a/Source/Kernel/VFS/Partition.class.cpp +++ b/Source/Kernel/VFS/Partition.class.cpp @@ -1,5 +1,7 @@ #include "Partition.class.h" +using namespace CMem; //For memcpy + Partition::Partition(BlockDevice* dev, u8int partnumber, u64int startblock, u64int blockcount) { m_device = dev; m_partnumber = partnumber; @@ -49,7 +51,7 @@ bool Partition::write(u64int start, u32int length, u8int *data) { if (!readBlocks(startBlock, 1, buff)) return false; } if (lastBlock != startBlock and (length + offset) % blksz != 0) { - if (!readBlocks(lastBlock, 1, buff + ((blocks - 1) * blksize))) return false; + if (!readBlocks(lastBlock, 1, buff + ((blocks - 1) * blksz))) return false; } memcpy(buff + offset, data, length); if (!writeBlocks(startBlock, blocks, buff)) return false; diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.cpp b/Source/Kernel/VTManager/VirtualTerminal.class.cpp index f5cec5f..dde487c 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.class.cpp +++ b/Source/Kernel/VTManager/VirtualTerminal.class.cpp @@ -29,7 +29,7 @@ void VirtualTerminal::setColor(u8int fgcolor, u8int bgcolor) { } } -void VirtualTerminal::putChar(u32int row, u32int col, wchar c) { +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; @@ -103,7 +103,7 @@ void VirtualTerminal::setCursorCol(u32int col) { // Display functionn -void VirtualTerminal::put(wchar c, bool updatecsr) { +void VirtualTerminal::put(WChar c, bool updatecsr) { if (c.value == '\b') { if (m_csrcol > 0) m_csrcol--; putChar(m_csrlin, m_csrcol, ' '); @@ -185,7 +185,7 @@ void VirtualTerminal::hexDump(u8int *ptr, u32int sz) { for (u32int j = 0; j < 16; j++) { u8int b = ptr[i + j]; if (b >= 0x20 && b < 128) { - put(wchar(b)); + put(WChar(b)); } else { put("."); } diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.h b/Source/Kernel/VTManager/VirtualTerminal.class.h index 4e5fe86..5739c72 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.class.h +++ b/Source/Kernel/VTManager/VirtualTerminal.class.h @@ -9,7 +9,7 @@ struct chr { u8int color; - wchar c; + WChar c; }; class VirtualTerminal { @@ -31,7 +31,7 @@ class VirtualTerminal { ~VirtualTerminal(); void setColor(u8int fgcolor, u8int bgcolor = 0xFF); - void putChar(u32int row, u32int col, wchar c); + void putChar(u32int row, u32int col, WChar c); void clear(); void map(s32int row = -1, s32int col = -1); @@ -45,7 +45,7 @@ class VirtualTerminal { void setCursorCol(u32int col); //Display functions - void put(wchar c, bool updatecsr = true); + void put(WChar c, bool updatecsr = true); void write(String s, bool updatecsr = true); void writeDec(s32int i, bool updatecsr = true); void writeHex(u32int i, bool updatecsr = true); @@ -53,7 +53,7 @@ class VirtualTerminal { void hexDump(u8int* ptr, u32int sz); inline VirtualTerminal& operator<<(String s) { write(s); return *this; } - //inline VirtualTerminal& operator<<(wchar c) { put(c); return *this; } + //inline VirtualTerminal& operator<<(WChar c) { put(c); return *this; } inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; } inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; } -- cgit v1.2.3