Ok. E-Exec now does command history of up to 15 items. Added

Epplet_change_textbox. Not thoroughly tested, but isn't that what users
are for? *runs*


SVN revision: 1261
This commit is contained in:
Richard Barnes 1999-11-12 03:46:39 +00:00
parent 5d299b6405
commit bf855d9279
4 changed files with 80 additions and 6 deletions

View File

@ -421,3 +421,13 @@ Added some code to do a command history. A change to the api is needed for it
to work, so I'm committing this first so I don't screw anything up during the
api modification. currently the relevant code is commented out.
-------------------------------------------------------------------------------
Thu Nov 11 22:59:14 EST 1999
(StriderZ)
changes to epplets/E-Exec.c api/epplet.c api/epplet.h
Ok. E-Exec now does command history of up to 15 items. Added
Epplet_change_textbox. Not thoroughly tested, but isn't that what users
are for? *runs*

View File

@ -1388,7 +1388,9 @@ Epplet_del_gad(Epplet_gadget gadget)
typedef struct
{
GadGeneral general;
int x, y, w, h, cursor_pos, text_offset;
int x, y, w, h;
int char_width, char_height;
int cursor_pos, text_offset, viewable_chars;
char *image;
char *contents;
char hilited;
@ -1424,6 +1426,25 @@ Epplet_create_textbox(char *image, char *contents, int x, int y,
g->mask = 0;
g->image = Estrdup(image);
g->hilited = 0;
switch (g->size)
{
case 0:
Epplet_textclass_get_size("EPPLET_BUTTON", &(g->char_width), &(g->char_height), "C");
break;
case 1:
Epplet_textclass_get_size("EPPLET_TEXT_TINY", &(g->char_width), &(g->char_height), "C");
break;
case 2:
Epplet_textclass_get_size("EPPLET_TEXT_MEDIUM", &(g->char_width), &(g->char_height), "C");
break;
case 3:
Epplet_textclass_get_size("EPPLET_LARG", &(g->char_width), &(g->char_height), "C");
break;
}
g->viewable_chars = g->w / g->char_width;
attr.backing_store = NotUseful;
attr.override_redirect = False;
attr.colormap = Imlib_get_colormap(id);
@ -1439,7 +1460,9 @@ Epplet_create_textbox(char *image, char *contents, int x, int y,
CWColormap | CWBackPixel | CWBorderPixel |
CWEventMask, &attr);
XSaveContext(disp, g->win, xid_context, (XPointer) g);
Epplet_add_gad((Epplet_gadget) g);
return (Epplet_gadget) g;
}
@ -1467,6 +1490,36 @@ Epplet_reset_textbox(Epplet_gadget eg)
g->cursor_pos = g->text_offset = 0;
}
void
Epplet_change_textbox(Epplet_gadget eg, char *new_contents)
{
GadTextBox *g;
int len;
len = strlen(new_contents);
g = (GadTextBox *) eg;
printf("old: %s -> new: %s\n", g->contents, new_contents);
if(g->contents != NULL)
free(g->contents);
g->contents = Estrdup(new_contents);
printf("now: %s\n", g->contents);
/*
if(len > g->viewable_chars)
g->cursor_pos = g->viewable_chars * g->char_width;
g->text_offset = len - g->viewable_chars;
*/
g->cursor_pos = g->text_offset = 0;
Epplet_draw_textbox(eg);
}
void
Epplet_draw_textbox(Epplet_gadget eg)
{
@ -1505,6 +1558,7 @@ Epplet_draw_textbox(Epplet_gadget eg)
Imlib_destroy_image(id, im);
}
}
if (g->contents)
{
int x, y, w, h;
@ -1518,7 +1572,10 @@ Epplet_draw_textbox(Epplet_gadget eg)
{
case 0:
Epplet_textclass_get_size("EPPLET_BUTTON", &w, &h, s);
s[w] = '\0';
if(strlen(s) > g->viewable_chars)
s[g->viewable_chars] = '\0';
y = (g->h - h) / 2;
Epplet_textclass_draw("EPPLET_BUTTON", state, g->pmap, x, y, s);
break;
@ -1542,6 +1599,7 @@ Epplet_draw_textbox(Epplet_gadget eg)
break;
}
}
ESYNC;
XSetWindowBackgroundPixmap(disp, g->win, g->pmap);
XShapeCombineMask(disp, g->win, ShapeBounding, 0, 0, g->mask, ShapeSet);
@ -1596,6 +1654,7 @@ Epplet_textbox_handle_keyevent(XEvent *ev, Epplet_gadget gadget)
g->contents = (char *) malloc(len + 1);
*(g->contents) = 0;
}
strcat(g->contents, kbuf);
if (g->cursor_pos <= g->w)
g->cursor_pos += len;

View File

@ -231,6 +231,9 @@ char *Epplet_textbox_contents(Epplet_gadget g);
/* Reset the textbox */
void Epplet_reset_textbox(Epplet_gadget eg);
/* Change the contents of a textbox */
void Epplet_change_textbox(Epplet_gadget eg, char *new_contents);
/* create drawing area at (x,y) of size (w x h) */
Epplet_gadget Epplet_create_drawingarea(int x, int y, int w, int h);
/* create horizontal slider at x, y of length len. the minimum length is 9 */

View File

@ -40,6 +40,8 @@ run_contents(void *data)
command_history[MAX_HIST_LEN] = strdup(command);
}
current_command = num_commands;
Epplet_spawn_command(command);
Epplet_reset_textbox(textbox);
return;
@ -49,15 +51,15 @@ run_contents(void *data)
static void
hist_last(void *data)
{
//if(current_command >= 0)
//Epplet_change_textbox(textbox, command_history[--current_command]);
if(current_command > 0)
Epplet_change_textbox(textbox, command_history[--current_command]);
}
static void
hist_next(void *data)
{
//if(current_command < num_commands)
//Epplet_change_textbox(textbox, command_history[++current_command]);
if(current_command < num_commands)
Epplet_change_textbox(textbox, command_history[++current_command]);
}
int