term: Add support for tabs

This commit is contained in:
mintsuki 2021-05-22 23:11:18 +02:00
parent a6a88109d7
commit 4d7a48eca7
3 changed files with 43 additions and 36 deletions

View File

@ -7,6 +7,8 @@
#include <lib/blib.h>
#include <drivers/vga_textmode.h>
#define TERM_TABSIZE (8)
int current_video_mode = -1;
int term_backend = NOT_READY;
@ -90,9 +92,14 @@ static void term_putchar(uint8_t c) {
switch (c) {
case 0x00:
break;
case 0x1B:
case '\e':
escape = 1;
return;
case '\t':
if ((get_cursor_pos_x() / TERM_TABSIZE + 1) >= term_cols)
break;
set_cursor_pos((get_cursor_pos_x() / TERM_TABSIZE + 1) * TERM_TABSIZE, get_cursor_pos_y());
break;
default:
raw_putchar(c);
break;

View File

@ -14,7 +14,7 @@ BACKDROP_COLOUR=008080
:Stivale2 Test
PROTOCOL=stivale2
RESOLUTION=640x480x16
RESOLUTION=800x600
KERNEL_PATH=boot:///boot/test.elf
KERNEL_CMDLINE=Woah! Another example!

View File

@ -79,89 +79,89 @@ void stivale2_main(struct stivale2_struct *info) {
case STIVALE2_STRUCT_TAG_CMDLINE_ID: {
struct stivale2_struct_tag_cmdline *c = (struct stivale2_struct_tag_cmdline *)tag;
e9_puts("Commandline tag:");
e9_printf(" Cmdline: %s", (char*)(c->cmdline));
e9_printf("\tCmdline: %s", (char*)(c->cmdline));
break;
}
case STIVALE2_STRUCT_TAG_MEMMAP_ID: {
struct stivale2_struct_tag_memmap *m = (struct stivale2_struct_tag_memmap *)tag;
e9_puts("Memmap tag:");
e9_printf(" Entries: %d", m->entries);
e9_printf("\tEntries: %d", m->entries);
for (size_t i = 0; i < m->entries; i++) {
struct stivale2_mmap_entry me = m->memmap[i];
e9_printf(" [%x+%x] %x", me.base, me.length, me.type);
e9_printf("\t\t[%x+%x] %x", me.base, me.length, me.type);
}
break;
}
case STIVALE2_STRUCT_TAG_FRAMEBUFFER_ID: {
struct stivale2_struct_tag_framebuffer *f = (struct stivale2_struct_tag_framebuffer *)tag;
e9_puts("Framebuffer tag:");
e9_printf(" Address: %x", f->framebuffer_addr);
e9_printf(" Width: %d", f->framebuffer_width);
e9_printf(" Height: %d", f->framebuffer_height);
e9_printf(" Pitch: %d", f->framebuffer_pitch);
e9_printf(" BPP: %d", f->framebuffer_bpp);
e9_printf(" Memory model: %d", f->memory_model);
e9_printf(" Red mask size: %d", f->red_mask_size);
e9_printf(" Red mask size: %d", f->red_mask_shift);
e9_printf(" Green mask size: %d", f->green_mask_size);
e9_printf(" Green mask size: %d", f->green_mask_shift);
e9_printf(" Blue mask size: %d", f->blue_mask_size);
e9_printf(" Blue mask size: %d", f->blue_mask_shift);
e9_printf("\tAddress: %x", f->framebuffer_addr);
e9_printf("\tWidth: %d", f->framebuffer_width);
e9_printf("\tHeight: %d", f->framebuffer_height);
e9_printf("\tPitch: %d", f->framebuffer_pitch);
e9_printf("\tBPP: %d", f->framebuffer_bpp);
e9_printf("\tMemory model: %d", f->memory_model);
e9_printf("\tRed mask size: %d", f->red_mask_size);
e9_printf("\tRed mask size: %d", f->red_mask_shift);
e9_printf("\tGreen mask size: %d", f->green_mask_size);
e9_printf("\tGreen mask size: %d", f->green_mask_shift);
e9_printf("\tBlue mask size: %d", f->blue_mask_size);
e9_printf("\tBlue mask size: %d", f->blue_mask_shift);
break;
}
case STIVALE2_STRUCT_TAG_EDID_ID: {
struct stivale2_struct_tag_edid *edid = (struct stivale2_struct_tag_edid *)tag;
e9_printf("EDID information at %x:", edid->edid_information);
e9_printf(" Size: %d", edid->edid_size);
e9_printf("\tSize: %d", edid->edid_size);
break;
}
case STIVALE2_STRUCT_TAG_FB_MTRR_ID: {
e9_puts("Framebuffer WC MTRR tag:");
e9_puts(" Framebuffer WC MTRR enabled");
e9_puts("\tFramebuffer WC MTRR enabled");
break;
}
case STIVALE2_STRUCT_TAG_TERMINAL_ID: {
struct stivale2_struct_tag_terminal *term = (struct stivale2_struct_tag_terminal *)tag;
e9_puts("Terminal tag:");
e9_printf(" Terminal write entry point at: %x", term->term_write);
e9_printf("\tTerminal write entry point at: %x", term->term_write);
break;
}
case STIVALE2_STRUCT_TAG_MODULES_ID: {
struct stivale2_struct_tag_modules *m = (struct stivale2_struct_tag_modules *)tag;
e9_puts("Modules tag:");
e9_printf(" Count: %d", m->module_count);
e9_printf("\tCount: %d", m->module_count);
for (size_t i = 0; i < m->module_count; i++) {
struct stivale2_module me = m->modules[i];
e9_printf(" [%x+%x] %s", me.begin, me.end, me.string);
e9_printf("\t\t[%x+%x] %s", me.begin, me.end, me.string);
}
break;
}
case STIVALE2_STRUCT_TAG_RSDP_ID: {
struct stivale2_struct_tag_rsdp *r = (struct stivale2_struct_tag_rsdp *)tag;
e9_puts("RSDP tag:");
e9_printf(" RSDP: %x", r->rsdp);
e9_printf("\tRSDP: %x", r->rsdp);
break;
}
case STIVALE2_STRUCT_TAG_SMBIOS_ID: {
struct stivale2_struct_tag_smbios *r = (struct stivale2_struct_tag_smbios *)tag;
e9_puts("SMBIOS tag:");
e9_printf(" Flags: %x", r->flags);
e9_printf(" SMBIOS 32-bit entry point: %x", r->smbios_entry_32);
e9_printf(" SMBIOS 64-bit entry point: %x", r->smbios_entry_64);
e9_printf("\tFlags: %x", r->flags);
e9_printf("\tSMBIOS 32-bit entry point: %x", r->smbios_entry_32);
e9_printf("\tSMBIOS 64-bit entry point: %x", r->smbios_entry_64);
break;
}
case STIVALE2_STRUCT_TAG_EPOCH_ID: {
struct stivale2_struct_tag_epoch *e = (struct stivale2_struct_tag_epoch *)tag;
e9_puts("Epoch tag:");
e9_printf(" Epoch: %x", e->epoch);
e9_printf("\tEpoch: %x", e->epoch);
break;
}
case STIVALE2_STRUCT_TAG_FIRMWARE_ID: {
struct stivale2_struct_tag_firmware *f = (struct stivale2_struct_tag_firmware *)tag;
e9_puts("Firmware tag:");
e9_printf(" Flags: %x", f->flags);
e9_printf("\tFlags: %x", f->flags);
break;
}
case STIVALE2_STRUCT_TAG_EFI_SYSTEM_TABLE_ID: {
@ -182,16 +182,16 @@ void stivale2_main(struct stivale2_struct *info) {
case STIVALE2_STRUCT_TAG_SMP_ID: {
struct stivale2_struct_tag_smp *s = (struct stivale2_struct_tag_smp *)tag;
e9_puts("SMP tag:");
e9_printf(" Flags: %x", s->flags);
e9_printf(" BSP LAPIC ID: %d", s->bsp_lapic_id);
e9_printf(" CPU Count: %d", s->cpu_count);
e9_printf("\tFlags: %x", s->flags);
e9_printf("\tBSP LAPIC ID: %d", s->bsp_lapic_id);
e9_printf("\tCPU Count: %d", s->cpu_count);
for (size_t i = 0; i < s->cpu_count; i++) {
struct stivale2_smp_info *in = &s->smp_info[i];
e9_printf(" Processor ID: %d", in->processor_id);
e9_printf(" LAPIC ID: %d", in->lapic_id);
e9_printf(" Target Stack: %x", in->target_stack);
e9_printf(" GOTO Address: %x", in->goto_address);
e9_printf(" Extra Argument: %x", in->extra_argument);
e9_printf("\t\tProcessor ID: %d", in->processor_id);
e9_printf("\t\tLAPIC ID: %d", in->lapic_id);
e9_printf("\t\tTarget Stack: %x", in->target_stack);
e9_printf("\t\tGOTO Address: %x", in->goto_address);
e9_printf("\t\tExtra Argument: %x", in->extra_argument);
if (in->lapic_id != s->bsp_lapic_id) {
in->target_stack = (uintptr_t)stacks[in->lapic_id] + sizeof(stack);
in->goto_address = (uintptr_t)ap_entry;