Terminal
git-svn-id: https://spexeah.com:8443/svn/Asuro@214 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
@ -77,6 +77,8 @@ procedure writebin32ln(b : uint32);
|
||||
procedure writebin32ex(b : uint32; attributes : char);
|
||||
procedure writebin32lnex(b : uint32; attributes : char);
|
||||
|
||||
procedure backspace;
|
||||
|
||||
function combinecolors(Foreground, Background : TColor) : char;
|
||||
|
||||
procedure _increment_x();
|
||||
@ -440,6 +442,14 @@ begin
|
||||
outb($3D5, b);
|
||||
end;
|
||||
|
||||
procedure backspace;
|
||||
begin
|
||||
Dec(Console_Cursor.X);
|
||||
writechar(' ');
|
||||
Dec(Console_Cursor.X);
|
||||
_update_cursor();
|
||||
end;
|
||||
|
||||
procedure _increment_x(); [public, alias: '_console_increment_x'];
|
||||
begin
|
||||
Console_Cursor.X:= Console_Cursor.X+1;
|
||||
|
@ -28,22 +28,28 @@ uses
|
||||
lmemorymanager,
|
||||
tss,
|
||||
scheduler,
|
||||
PCI;
|
||||
PCI,
|
||||
Terminal;
|
||||
|
||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
|
||||
|
||||
implementation
|
||||
|
||||
procedure temphook(ignored : TKeyInfo);
|
||||
begin
|
||||
Terminal.run;
|
||||
end;
|
||||
|
||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
|
||||
var
|
||||
c : uint8;
|
||||
z : uint32;
|
||||
dds : uint32;
|
||||
pint : puint32;
|
||||
pint2 : puint32;
|
||||
c : uint8;
|
||||
z : uint32;
|
||||
dds : uint32;
|
||||
pint : puint32;
|
||||
pint2 : puint32;
|
||||
keyboard_layout : array [0..1] of TKeyInfo;
|
||||
i : uint32;
|
||||
cEIP : uint32;
|
||||
i : uint32;
|
||||
cEIP : uint32;
|
||||
|
||||
begin
|
||||
multibootinfo:= mbinfo;
|
||||
@ -105,7 +111,10 @@ begin
|
||||
console.writestring('Total Memory = ');
|
||||
console.writeint(((mbinfo^.mem_upper + 1000) div 1024) + 1);
|
||||
console.writestringln('MB');
|
||||
console.setdefaultattribute(console.combinecolors(lYellow, Black));
|
||||
console.setdefaultattribute(console.combinecolors(White, Black));
|
||||
console.writestringln('');
|
||||
console.writestringln('Press any key to boot in to Asuro Terminal...');
|
||||
keyboard.hook(@temphook);
|
||||
util.halt_and_dont_catch_fire;
|
||||
end;
|
||||
|
||||
|
52
src/terminal.pas
Normal file
52
src/terminal.pas
Normal file
@ -0,0 +1,52 @@
|
||||
unit terminal;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
console,
|
||||
keyboard;
|
||||
|
||||
var
|
||||
buffer : array[0..1024] of byte;
|
||||
bIndex : uint32 = 0;
|
||||
|
||||
procedure run;
|
||||
|
||||
implementation
|
||||
|
||||
procedure process_command;
|
||||
begin
|
||||
console.writecharln(' ');
|
||||
console.writestring('Asuro#> ');
|
||||
bIndex:= 0;
|
||||
end;
|
||||
|
||||
procedure key_event(info : TKeyInfo);
|
||||
begin
|
||||
if (info.key_code >= 32) and (info.key_code <= 126) then begin
|
||||
if bIndex <= 1024 then begin
|
||||
buffer[bIndex]:= info.key_code;
|
||||
inc(bIndex);
|
||||
console.writechar(char(info.key_code));
|
||||
end;
|
||||
end;
|
||||
if info.key_code = 8 then begin //backspace
|
||||
if bIndex > 0 then begin
|
||||
console.backspace;
|
||||
dec(bIndex);
|
||||
buffer[bIndex]:= 0;
|
||||
end;
|
||||
end;
|
||||
if info.key_code = 13 then begin //return
|
||||
process_command;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure run;
|
||||
begin
|
||||
keyboard.hook(@key_event);
|
||||
console.clear();
|
||||
console.writestring('Asuro#> ');
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user