Updated the build files to use $(xCP), allows use of mcopy to a mtools disk
[tpg/acess2.git] / Kernel / drv / vterm.c
index 87f71ed..4095feb 100644 (file)
@@ -16,8 +16,8 @@
 #define MAX_INPUT_CHARS32      64
 #define MAX_INPUT_CHARS8       (MAX_INPUT_CHARS32*4)
 #define VT_SCROLLBACK  1       // 2 Screens of text
-//#define DEFAULT_OUTPUT       "VGA"
-#define DEFAULT_OUTPUT "BochsGA"
+#define DEFAULT_OUTPUT "VGA"
+//#define DEFAULT_OUTPUT       "BochsGA"
 #define DEFAULT_INPUT  "PS2Keyboard"
 #define        DEFAULT_WIDTH   80
 #define        DEFAULT_HEIGHT  25
@@ -197,7 +197,6 @@ int VT_Install(char **Arguments)
 void VT_InitOutput()
 {
        giVT_OutputDevHandle = VFS_Open(gsVT_OutputDevice, VFS_OPENFLAG_WRITE);
-       Log("giVT_OutputDevHandle = %x\n", giVT_OutputDevHandle);
        VT_SetTerminal( 0 );
 }
 
@@ -208,7 +207,6 @@ void VT_InitOutput()
 void VT_InitInput()
 {
        giVT_InputDevHandle = VFS_Open(gsVT_InputDevice, VFS_OPENFLAG_READ);
-       LOG("giVT_InputDevHandle = %x\n", giVT_InputDevHandle);
        if(giVT_InputDevHandle == -1)   return ;
        VFS_IOCtl(giVT_InputDevHandle, KB_IOCTL_SETCALLBACK, VT_KBCallBack);
 }
@@ -427,7 +425,7 @@ void VT_SetTerminal(int ID)
        modeNum = mode.id;
        gVT_Terminals[ ID ].RealWidth = mode.width;
        gVT_Terminals[ ID ].RealHeight = mode.height;
-       VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_SETMODE, &modeNum );
+       VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &modeNum );
        
        // Update current terminal ID
        Log("Changed terminal from %i to %i", giVT_CurrentTerminal, ID);
@@ -495,9 +493,9 @@ void VT_KBCallBack(Uint32 Codepoint)
                case KEY_F11:   VT_SetTerminal(10);     return;
                case KEY_F12:   VT_SetTerminal(11);     return;
                case KEY_PGUP:
-                       break;
+                       return;
                case KEY_PGDOWN:
-                       break;
+                       return;
                }
        }
        
@@ -505,7 +503,7 @@ void VT_KBCallBack(Uint32 Codepoint)
        if(term->Mode == TERM_MODE_TEXT)
        {
                Uint8   buf[6] = {0};
-                int    len;
+                int    len = 0;
                
                // Ignore Modifer Keys
                if(Codepoint > KEY_MODIFIERS)   return;
@@ -514,20 +512,43 @@ void VT_KBCallBack(Uint32 Codepoint)
                switch(Codepoint)
                {
                case KEY_LEFT:
-                       buf[0] = '\x1B';        buf[1] = '[';
-                       buf[2] = 'D';   len = 3;
+                       buf[0] = '\x1B';        buf[1] = '[';   buf[2] = 'D';
+                       len = 3;
                        break;
                case KEY_RIGHT:
-                       buf[0] = '\x1B';        buf[1] = '[';
-                       buf[2] = 'C';   len = 3;
+                       buf[0] = '\x1B';        buf[1] = '[';   buf[2] = 'C';
+                       len = 3;
+                       break;
+               case KEY_UP:
+                       buf[0] = '\x1B';        buf[1] = '[';   buf[2] = 'A';
+                       len = 3;
+                       break;
+               case KEY_DOWN:
+                       buf[0] = '\x1B';        buf[1] = '[';   buf[2] = 'B';
+                       len = 3;
+                       break;
+               
+               case KEY_PGUP:
+                       buf[0] = '\x1B';        buf[1] = '[';   buf[2] = '5';   // Some overline also
+                       //len = 4;      // Commented out until I'm sure
+                       break;
+               case KEY_PGDOWN:
+                       len = 0;
                        break;
+               
+               // Attempt to encode in UTF-8
                default:
                        len = WriteUTF8( buf, Codepoint );
-                       //Log("Codepoint = 0x%x", Codepoint);
+                       if(len == 0) {
+                               Warning("Codepoint (%x) is unrepresentable in UTF-8", Codepoint);
+                       }
                        break;
                }
                
-               //Log("len = %i, buf = %s", len, buf);
+               if(len == 0) {
+                       // Unprintable / Don't Pass
+                       return;
+               }
                
                // Write
                if( MAX_INPUT_CHARS8 - term->InputWrite >= len )

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