Usermode/axwin3 - Little additions and bugfixes
authorJohn Hodge <[email protected]>
Sun, 11 Mar 2012 06:24:35 +0000 (14:24 +0800)
committerJohn Hodge <[email protected]>
Sun, 11 Mar 2012 06:24:35 +0000 (14:24 +0800)
KernelLand/Kernel/include/keysyms.h
Usermode/Applications/axwin3_src/Interface/main.c
Usermode/Applications/axwin3_src/WM/input.c
Usermode/Applications/axwin3_src/WM/renderers/widget/textinput.c
Usermode/Applications/axwin3_src/include/widget_messages.h
Usermode/Applications/axwin3_src/libaxwin3.so_src/main.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/r_widget.c
Usermode/include/axwin3/widget.h

index caabb4e..d240ef3 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Acess2 USB Stack HID Driver
+ * Acess2 Kernel
  * - By John Hodge (thePowersGang)
  *
- * usb_keysyms.h
+ * keysyms.h
  * - USB HID Keyboard Symbols
  */
 #ifndef _USB_KEYSYMS_H_
index 80bf329..e34968c 100644 (file)
@@ -125,15 +125,20 @@ void create_mainmenu(void)
        AxWin3_Menu_AddItem(gSystemMenu, "&Run\tWin+R", mainmenu_run_dialog, NULL, 0, NULL);
 }
 
+// --------------------------------------------------------------------
+// "Run" Dialog box
+// --------------------------------------------------------------------
 int run_dorun(tAxWin3_Widget *unused)
 {
-//     char *cmd = AxWin3_Widget_GetText(gRunInput);
+       char *cmd = AxWin3_Widget_GetText(gRunInput);
+       _SysDebug("Command string '%s'", cmd);
        AxWin3_ShowWindow(gRunDialog, 0);
        return 0;
 }
 
 int run_close(tAxWin3_Widget *unused)
 {
+       _SysDebug("Run diaglog closed");
        AxWin3_ShowWindow(gRunDialog, 0);
        return 0;
 }
index 9fe73ff..bd23c0b 100644 (file)
@@ -125,8 +125,7 @@ void Input_HandleSelect(fd_set *set)
                        return ;
                }
                if( mouseinfo->NAxies > c_n_axies || mouseinfo->NButtons > c_n_buttons ) {
-                       _SysDebug(
-                               "%i axies, %i buttons above prealloc counts (%i, %i)",
+                       _SysDebug("%i axies, %i buttons above prealloc counts (%i, %i)",
                                mouseinfo->NAxies, mouseinfo->NButtons, c_n_axies, c_n_buttons
                                );
                        return ;
index 2e21e78..9a0ae64 100644 (file)
 #include <utf8.h>
 #include <string.h>
 
+// TODO: Include a proper keysym header
+#define KEYSYM_LEFTARROW       0x50
+#define KEYSYM_RIGHTARROW      0x4F
+
 struct sTextInputInfo
 {
         int    DrawOfs;        // Byte offset for the leftmost character
@@ -128,7 +132,26 @@ int Widget_TextInput_KeyFire(tElement *Element, int KeySym, int Character)
 //     _SysDebug("Key 0x%x fired ('%c')", Character, Character);
        
        if( Character == 0 )
+       {
+               switch(KeySym)
+               {
+               case KEYSYM_LEFTARROW:
+                       if( info->CursorByteOfs > 0 )
+                       {
+                               len = ReadUTF8Rev(Element->Text, info->CursorByteOfs, &cp);
+                               info->CursorByteOfs -= len;
+                       }
+                       break;
+               case KEYSYM_RIGHTARROW:
+                       if( info->CursorByteOfs < info->Length )
+                       {
+                               len = ReadUTF8(Element->Text + info->CursorByteOfs, &cp);
+                               info->CursorByteOfs += len;
+                       }
+                       break;
+               }
                return 0;
+       }
 
        // TODO: Don't hard code
        if(Character > 0x30000000)      return 0;
index 53e7dcc..0a4b250 100644 (file)
@@ -19,6 +19,10 @@ enum
        MSG_WIDGET_SETTEXT,
        MSG_WIDGET_SETCOLOUR,
        
+
+       // Request (Client->Server->Client) messages
+       MSG_WIDGET_GETTEXT,
+
        // Event (Server->Client) messages
        MSG_WIDGET_FIRE,
        MSG_WIDGET_KEYPRESS,
index fcd572a..d8f6a61 100644 (file)
@@ -28,7 +28,6 @@ void AxWin3_MainLoop(void)
                msg = AxWin3_int_GetIPCMessage();
                if(!msg)        continue;       
 
-               // TODO: Handle message
                _SysDebug("oh look, a message (Type=%i, Window=%i, Len=%i)",
                        msg->ID, msg->Window, msg->Size);
 
index b03d64d..17d089f 100644 (file)
@@ -121,8 +121,7 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
        switch(giConnectionType)
        {
        case CONNTYPE_SENDMESSAGE:
-               // TODO: Less hack, I need a version of select for GetMessage etc
-               if(SysGetMessage(NULL, NULL) == 0)      _SysWaitEvent(THREAD_EVENT_IPCMSG);
+               _SysWaitEvent(THREAD_EVENT_IPCMSG);
                while(SysGetMessage(NULL, NULL))
                {
                        pid_t   tid;
index 17dd16e..875f14b 100644 (file)
@@ -8,6 +8,7 @@
 #include <axwin3/axwin.h>
 #include <axwin3/widget.h>
 #include "include/internal.h"
+#include "include/ipc.h"
 #include <stdlib.h>
 #include <widget_messages.h>
 #include <string.h>
@@ -227,6 +228,30 @@ void AxWin3_Widget_SetText(tAxWin3_Widget *Widget, const char *Text)
        AxWin3_SendMessage(Widget->Window, Widget->Window, MSG_WIDGET_SETTEXT, sizeof(buf), buf);
 }
 
+char *AxWin3_Widget_GetText(tAxWin3_Widget *Widget)
+{
+       char    buf[sizeof(tWidgetMsg_SetText)];
+       tWidgetMsg_SetText      *msg = (void*)buf;
+       tAxWin_IPCMessage       *retmsg;
+       char    *ret;
+       
+       msg->WidgetID = Widget->ID;
+
+       AxWin3_SendMessage(Widget->Window, Widget->Window, MSG_WIDGET_GETTEXT, sizeof(buf), buf);
+
+       retmsg = AxWin3_int_WaitIPCMessage(MSG_WIDGET_GETTEXT);
+       msg = (void*)retmsg->Data;
+
+       if( retmsg->Size < sizeof(*msg) ) {
+               free(retmsg);
+               return NULL;
+       }
+
+       ret = strndup(msg->Text, retmsg->Size - sizeof(*msg));
+       free(retmsg);
+       return ret;
+}
+
 void AxWin3_Widget_SetColour(tAxWin3_Widget *Widget, int Index, tAxWin3_Colour Colour)
 {
        tWidgetMsg_SetColour    msg;
index 0329425..29a0225 100644 (file)
@@ -39,6 +39,8 @@ extern void   AxWin3_Widget_SetFlags(tAxWin3_Widget *Widget, int FlagSet, int Flag
 extern void    AxWin3_Widget_SetSize(tAxWin3_Widget *Widget, int Size);
 extern void    AxWin3_Widget_SetText(tAxWin3_Widget *Widget, const char *Text);
 extern void    AxWin3_Widget_SetColour(tAxWin3_Widget *Widget, int Index, tAxWin3_Colour Colour);
+// --- Inspection
+extern char    *AxWin3_Widget_GetText(tAxWin3_Widget *Widget);
 
 enum eElementTypes
 {

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