add ui_inputbox_set_text
authorChris Taylor <chris@icculus.org>
Sun, 3 Jul 2005 03:08:25 +0000 (03:08 +0000)
committerChris Taylor <chris@icculus.org>
Sun, 3 Jul 2005 03:08:25 +0000 (03:08 +0000)
ChangeLog
include/ui.h
ui/file.c
ui/inputbox.c

index 8548769..9e26b6b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-07-03  Chris Taylor  <chris@icculus.org>
+
+       * include/ui.h, ui/file.c, ui/inputbox.c: add ui_inputbox_set_text
+
 2005-07-01  Chris Taylor  <chris@icculus.org>
 
        * include/ui.h, main/editor/centers.c, main/editor/eswitch.c,
index abbac10..e2bf456 100644 (file)
@@ -307,6 +307,7 @@ extern void ui_listbox_change(UI_WINDOW *wnd, UI_GADGET_LISTBOX *listbox, short
 extern void ui_draw_inputbox( UI_GADGET_INPUTBOX * inputbox );
 extern UI_GADGET_INPUTBOX * ui_add_gadget_inputbox( UI_WINDOW * wnd, short x, short y, short w, short h, char * text );
 extern void ui_inputbox_do( UI_GADGET_INPUTBOX * inputbox, int keypress );
+extern void ui_inputbox_set_text(UI_GADGET_INPUTBOX *inputbox, char *text);
 
 
 extern void ui_userbox_do( UI_GADGET_USERBOX * userbox, int keypress );
index 0531ef8..3282a37 100644 (file)
--- a/ui/file.c
+++ b/ui/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.11 2005-03-05 09:30:26 chris Exp $ */
+/* $Id: file.c,v 1.12 2005-07-03 03:08:25 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 
 #ifdef RCS
-static char rcsid[] = "$Id: file.c,v 1.11 2005-03-05 09:30:26 chris Exp $";
+static char rcsid[] = "$Id: file.c,v 1.12 2005-07-03 03:08:25 chris Exp $";
 #endif
 
 #include <stdlib.h>
@@ -218,25 +218,13 @@ int ui_get_filename( char * filename, char * Filespec, char * message  )
                if (ListBox1->moved || new_listboxes)
                {
                        if (ListBox1->current_item >= 0 )
-                       {
-                               strcpy(UserFile->text, filename_list[ListBox1->current_item] );
-                               UserFile->position = strlen(UserFile->text);
-                               UserFile->oldposition = UserFile->position;
-                               UserFile->status=1;
-                               UserFile->first_time = 1;
-                       }
+                               ui_inputbox_set_text(UserFile, filename_list[ListBox1->current_item]);
                }
 
                if (ListBox2->moved || new_listboxes)
                {
                        if (ListBox2->current_item >= 0 )
-                       {
-                               strcpy(UserFile->text, directory_list[ListBox2->current_item]);
-                               UserFile->position = strlen(UserFile->text);
-                               UserFile->oldposition = UserFile->position;
-                               UserFile->status=1;
-                               UserFile->first_time = 1;
-                       }
+                               ui_inputbox_set_text(UserFile, directory_list[ListBox2->current_item]);
                }
                new_listboxes = 0;
 
@@ -305,11 +293,7 @@ int ui_get_filename( char * filename, char * Filespec, char * message  )
                                        return 0;
                                }
 
-                               strcpy(UserFile->text, Filespec);
-                               UserFile->position = strlen(UserFile->text);
-                               UserFile->oldposition = UserFile->position;
-                               UserFile->status=1;
-                               UserFile->first_time = 1;
+                               ui_inputbox_set_text(UserFile, Filespec);
 
                                PHYSFS_freeList(directory_list);
                                directory_list = file_getdirlist(&NumDirs, ViewDir);
index 979ac87..829e45b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: inputbox.c,v 1.6 2005-02-26 09:50:36 chris Exp $ */
+/* $Id: inputbox.c,v 1.7 2005-07-03 03:08:25 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 
 #ifdef RCS
-static char rcsid[] = "$Id: inputbox.c,v 1.6 2005-02-26 09:50:36 chris Exp $";
+static char rcsid[] = "$Id: inputbox.c,v 1.7 2005-07-03 03:08:25 chris Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -165,3 +165,13 @@ void ui_inputbox_do( UI_GADGET_INPUTBOX * inputbox, int keypress )
        ui_draw_inputbox( inputbox );
 
 }
+
+void ui_inputbox_set_text(UI_GADGET_INPUTBOX *inputbox, char *text)
+{
+       strncpy(inputbox->text, text, inputbox->length + 1);
+       inputbox->position = strlen(text);
+       inputbox->oldposition = inputbox->position;
+       inputbox->status = 1;           // redraw
+       inputbox->first_time = 1;       // select all
+}
+