CTAOS v6
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
rem NASM and DJGPP executable paths:
|
||||
set nasm_path=C:\nasm
|
||||
set djgpp_path=C:\DJGPP\bin
|
||||
set djgpp_path=C:\mingw\bin
|
||||
set objpath=..\objects
|
||||
set incpath=../include
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <conio.h>
|
||||
#include <hal.h>
|
||||
#include <drivers/keyboard.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@@ -25,6 +25,7 @@ UPoint ScreenSize, Cursor;
|
||||
|
||||
void ConsoleInstall(ConsoleScreen screen)
|
||||
{
|
||||
|
||||
_console_cursor = screen.cursor;
|
||||
_console_putc = screen.putc;
|
||||
_console_getc = screen.getc;
|
||||
@@ -199,7 +200,7 @@ int cgets(char* string, int maxlen)
|
||||
memset ((void*)string, 0, maxlen);
|
||||
|
||||
int Len = 0, CurPos = 0;
|
||||
kb_key Key;
|
||||
KeyboardKey Key;
|
||||
UPoint CursorSave;
|
||||
|
||||
while (Len < maxlen)
|
||||
@@ -216,38 +217,38 @@ int cgets(char* string, int maxlen)
|
||||
Cursor = CursorSave;
|
||||
|
||||
// Get key and process
|
||||
Key = getkey();
|
||||
Key = GetKey();
|
||||
|
||||
switch (Key.scancode) {
|
||||
switch (Key.Scancode) {
|
||||
// Switch overwrite/insert
|
||||
case KB_KEY_INSERT: __cgets__key_insert(); break;
|
||||
case KeyboardKeyInsert: __cgets__key_insert(); break;
|
||||
|
||||
// Finish writing (return)
|
||||
case KB_KEY_ENTER: __cgets__key_enter(); break;
|
||||
case KB_KEY_NUMPAD_ENTER: __cgets__key_enter(); break;
|
||||
case KeyboardKeyReturn: __cgets__key_enter(); break;
|
||||
case KeyboardKeyNumpadEnter: __cgets__key_enter(); break;
|
||||
|
||||
// Left
|
||||
case KB_KEY_LEFT:
|
||||
__cgets__move_cursor(string, 0, Len, &CurPos, ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL)));
|
||||
case KeyboardKeyLeft:
|
||||
__cgets__move_cursor(string, 0, Len, &CurPos, ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl)));
|
||||
break;
|
||||
|
||||
// Right
|
||||
case KB_KEY_RIGHT:
|
||||
__cgets__move_cursor(string, 1, Len, &CurPos, ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL)));
|
||||
case KeyboardKeyRight:
|
||||
__cgets__move_cursor(string, 1, Len, &CurPos, ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl)));
|
||||
break;
|
||||
|
||||
case KB_KEY_HOME:
|
||||
case KeyboardKeyHome:
|
||||
CurPos = 0;
|
||||
break;
|
||||
|
||||
case KB_KEY_END:
|
||||
case KeyboardKeyEnd:
|
||||
CurPos = Len;
|
||||
break;
|
||||
|
||||
case KB_KEY_BACKSPACE:
|
||||
case KeyboardKeyBackspace:
|
||||
if (CurPos > 0) {
|
||||
int tmp;
|
||||
if ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL))
|
||||
if ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl))
|
||||
tmp = __cgets__skip_word(string, Len, CurPos, 0);
|
||||
else tmp = CurPos-1;
|
||||
|
||||
@@ -258,11 +259,11 @@ int cgets(char* string, int maxlen)
|
||||
break;
|
||||
|
||||
// Delete
|
||||
case KB_KEY_DELETE:
|
||||
case KeyboardKeyDelete:
|
||||
if (CurPos < Len) {
|
||||
int tmp;
|
||||
// If CTRL is pressed, foward one word
|
||||
if ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL))
|
||||
if ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl))
|
||||
tmp = __cgets__skip_word(string, Len, CurPos, 1);
|
||||
else tmp = CurPos+1;
|
||||
|
||||
@@ -274,22 +275,22 @@ int cgets(char* string, int maxlen)
|
||||
|
||||
// Text character
|
||||
default:
|
||||
if (isprint(Key.character)) {
|
||||
if (isprint(Key.Character)) {
|
||||
// fix CAPS bug
|
||||
if ((Key.lights & KB_KEY_CAPS) && islower((unsigned char)Key.character))
|
||||
Key.character = toupper(Key.character);
|
||||
if ((Key.Lights & KeyboardLightCaps) && islower((unsigned char)Key.Character))
|
||||
Key.Character = toupper(Key.Character);
|
||||
|
||||
// Cursor is at the end of the string
|
||||
if (CurPos == Len) {
|
||||
Len++; string[Len-1] = Key.character;
|
||||
Len++; string[Len-1] = Key.Character;
|
||||
string[Len] = 0;
|
||||
}
|
||||
|
||||
// Cursor is not at the end in OverWrite mode
|
||||
else if (OverWrite) string[CurPos] = Key.character;
|
||||
else if (OverWrite) string[CurPos] = Key.Character;
|
||||
|
||||
// Cursor is not at the end in Insert mode
|
||||
else __cgets__insert(string, CurPos, Key.character, &Len);
|
||||
else __cgets__insert(string, CurPos, Key.Character, &Len);
|
||||
|
||||
// Increase cursor position
|
||||
CurPos++;
|
||||
@@ -361,13 +362,13 @@ int cputs(const char* str)
|
||||
|
||||
int getch()
|
||||
{
|
||||
kb_key k;
|
||||
k = getkey();
|
||||
KeyboardKey k;
|
||||
k = GetKey();
|
||||
|
||||
if ((k.lights & KB_KEY_CAPS) && k.character >= 'a' && k.character <= 'z')
|
||||
return (int)(k.character - 'a' + 'A');
|
||||
if ((k.Lights & KeyboardLightCaps) && k.Character >= 'a' && k.Character <= 'z')
|
||||
return (int)(k.Character - 'a' + 'A');
|
||||
|
||||
return k.character;
|
||||
return k.Character;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user