From: John Hodge Date: Mon, 20 May 2013 08:18:39 +0000 (+0800) Subject: Kernel/VTerm,PTY - Replaced VTerm buffers with PTY hooks X-Git-Tag: rel0.15~461 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ddc8417ddc723a656241915220e44930d4b6af85;p=tpg%2Facess2.git Kernel/VTerm,PTY - Replaced VTerm buffers with PTY hooks --- diff --git a/KernelLand/Kernel/Makefile b/KernelLand/Kernel/Makefile index 1628f9b9..f6820132 100644 --- a/KernelLand/Kernel/Makefile +++ b/KernelLand/Kernel/Makefile @@ -60,6 +60,7 @@ OBJ += messages.o modules.o syscalls.o system.o OBJ += threads.o mutex.o semaphore.o workqueue.o events.o rwlock.o OBJ += drv/zero-one.o drv/proc.o drv/fifo.o drv/dgram_pipe.o drv/iocache.o drv/pci.o drv/vpci.o OBJ += drv/vterm.o drv/vterm_font.o drv/vterm_vt100.o drv/vterm_output.o drv/vterm_input.o drv/vterm_termbuf.o +OBJ += drv/vterm_2d.o OBJ += drv/pty.o OBJ += binary.o bin/elf.o bin/pe.o OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/dir.o vfs/io.o vfs/mount.o diff --git a/KernelLand/Kernel/drv/pty.c b/KernelLand/Kernel/drv/pty.c index abfd9d14..8f4302d2 100644 --- a/KernelLand/Kernel/drv/pty.c +++ b/KernelLand/Kernel/drv/pty.c @@ -5,7 +5,7 @@ * drv/pty.c * - Pseudo Terminals */ -#define DEBUG 1 +#define DEBUG 0 #include #include #include @@ -104,7 +104,8 @@ tDevFS_Driver gPTY_Driver = { .Name = "pts", .RootNode = { .Flags = VFS_FFLAG_DIRECTORY, - .Type = &gPTY_NodeType_Root + .Type = &gPTY_NodeType_Root, + .Size = -1 } }; int giPTY_NumCount; @@ -434,37 +435,42 @@ size_t PTY_SendInput(tPTY *PTY, const char *Input, size_t Length) int PTY_ReadDir(tVFS_Node *Node, int Pos, char Name[FILENAME_MAX]) { tPTY *pty = NULL; - if( Pos < giPTY_NumCount * 2 ) + int idx = Pos; + if( idx < giPTY_NumCount * 2 ) { RWLock_AcquireRead(&glPTY_NumPTYs); for( pty = gpPTY_FirstNumPTY; pty; pty = pty->Next ) { - if( Pos < 2 ) + if( idx < 2 ) break; - Pos -= 2; + idx -= 2; } RWLock_Release(&glPTY_NumPTYs); } - else if( Pos < (giPTY_NumCount + giPTY_NamedCount) * 2 ) + else if( idx < (giPTY_NumCount + giPTY_NamedCount) * 2 ) { + idx -= giPTY_NumCount*2; RWLock_AcquireRead(&glPTY_NamedPTYs); for( pty = gpPTY_FirstNamedPTY; pty; pty = pty->Next ) { - if( Pos < 2 ) + if( idx < 2 ) break; - Pos -= 2; + idx -= 2; } RWLock_Release(&glPTY_NamedPTYs); } - if( !pty ) + if( !pty ) { + LOG("%i out of range", Pos); return -1; + } if( pty->Name[0] ) - snprintf(Name, FILENAME_MAX, "%s%c", pty->Name, (Pos == 0 ? 'c' : 's')); + snprintf(Name, FILENAME_MAX, "%s%c", pty->Name, (idx == 0 ? 'c' : 's')); else - snprintf(Name, FILENAME_MAX, "%i%c", pty->NumericName, (Pos == 0 ? 'c' : 's')); + snprintf(Name, FILENAME_MAX, "%i%c", pty->NumericName, (idx == 0 ? 'c' : 's')); + LOG("Return '%s'", Name); return 0; } diff --git a/KernelLand/Kernel/drv/vterm.c b/KernelLand/Kernel/drv/vterm.c index dc39cb30..dcd798b3 100644 --- a/KernelLand/Kernel/drv/vterm.c +++ b/KernelLand/Kernel/drv/vterm.c @@ -381,6 +381,7 @@ void VT_PTYOutput(void *Handle, size_t Length, const void *Data) break; case PTYBUFFMT_2DCMD: // TODO: Impliment 2D commands + VT_int_Handle2DCmd(term, Length, Data); break; case PTYBUFFMT_3DCMD: // TODO: Impliment 3D commands @@ -404,6 +405,8 @@ int VT_PTYModeset(void *Handle, const struct ptymode *Mode) tVTerm *term = Handle; term->Mode = (Mode->OutputMode & PTYOMODE_BUFFMT); + memset(&term->Cmd2D, 0, sizeof(term->Cmd2D)); + if( term == gpVT_CurTerm ) { switch(term->Mode) { diff --git a/KernelLand/Kernel/drv/vterm.h b/KernelLand/Kernel/drv/vterm.h index 7b01366f..39cc4386 100644 --- a/KernelLand/Kernel/drv/vterm.h +++ b/KernelLand/Kernel/drv/vterm.h @@ -78,6 +78,15 @@ struct sVTerm // Call set again, it's freed, and if NULL it doesn't get reallocated. tVideo_IOCtl_Bitmap *VideoCursor; + struct { + int Current; + size_t CurrentSize; + size_t Offset; + int CachePos; + char Cache[32]; + size_t PreEat; + } Cmd2D; + tPTY *PTY; }; @@ -94,6 +103,7 @@ extern int giVT_InputDevHandle; // === FUNCTIONS === extern void VT_SetResolution(int Width, int Height); extern void VT_SetTerminal(int ID); +extern void VT_int_Handle2DCmd(void *Handle, size_t Length, const void *Data); // --- Output --- extern void VT_InitOutput(void); extern void VT_SetMode(int Mode);