Kernel/VTerm,PTY - Replaced VTerm buffers with PTY hooks
authorJohn Hodge <[email protected]>
Mon, 20 May 2013 08:18:39 +0000 (16:18 +0800)
committerJohn Hodge <[email protected]>
Mon, 20 May 2013 08:18:39 +0000 (16:18 +0800)
KernelLand/Kernel/Makefile
KernelLand/Kernel/drv/pty.c
KernelLand/Kernel/drv/vterm.c
KernelLand/Kernel/drv/vterm.h

index 1628f9b..f682013 100644 (file)
@@ -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
index abfd9d1..8f4302d 100644 (file)
@@ -5,7 +5,7 @@
  * drv/pty.c
  * - Pseudo Terminals
  */
-#define DEBUG  1
+#define DEBUG  0
 #include <acess.h>
 #include <vfs.h>
 #include <fs_devfs.h>
@@ -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;
 }
 
index dc39cb3..dcd798b 100644 (file)
@@ -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)
                {
index 7b01366..39cc438 100644 (file)
@@ -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);

UCC git Repository :: git.ucc.asn.au