mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
Adjust shell GUI to the new shell logic.
This commit is contained in:
parent
fe6a55d1a4
commit
b2bcdfd55b
@ -28,11 +28,10 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki desktop OS.
|
* This file is part of the Contiki desktop OS.
|
||||||
*
|
*
|
||||||
* $Id: shell-gui.c,v 1.3 2006/12/29 23:05:19 oliverschmidt Exp $
|
* $Id: shell-gui.c,v 1.4 2008/02/07 23:08:48 oliverschmidt Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "program-handler.h"
|
#include "program-handler.h"
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
|
||||||
@ -54,7 +53,6 @@
|
|||||||
#define SHELL_GUI_YSIZE 10
|
#define SHELL_GUI_YSIZE 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static struct ctk_window window;
|
static struct ctk_window window;
|
||||||
static char log[SHELL_GUI_XSIZE * SHELL_GUI_YSIZE];
|
static char log[SHELL_GUI_XSIZE * SHELL_GUI_YSIZE];
|
||||||
static struct ctk_label loglabel =
|
static struct ctk_label loglabel =
|
||||||
@ -66,6 +64,10 @@ static struct ctk_textentry commandentry =
|
|||||||
|
|
||||||
PROCESS(shell_gui_process, "Command shell");
|
PROCESS(shell_gui_process, "Command shell");
|
||||||
|
|
||||||
|
#if SELFSTART_PROCESS
|
||||||
|
AUTOSTART_PROCESSES(&shell_gui_process);
|
||||||
|
#endif /* SELFSTART_PROCESS */
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
shell_quit(char *str)
|
shell_quit(char *str)
|
||||||
@ -76,24 +78,30 @@ shell_quit(char *str)
|
|||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
shell_output(char *str1, char *str2)
|
shell_default_output(const char *str1, int len1, const char *str2, int len2)
|
||||||
{
|
{
|
||||||
static unsigned char i, len;
|
static unsigned char i;
|
||||||
|
|
||||||
for(i = 1; i < SHELL_GUI_YSIZE; ++i) {
|
for(i = 1; i < SHELL_GUI_YSIZE; ++i) {
|
||||||
memcpy(&log[(i - 1) * SHELL_GUI_XSIZE],
|
memcpy(&log[(i - 1) * SHELL_GUI_XSIZE],
|
||||||
&log[i * SHELL_GUI_XSIZE], SHELL_GUI_XSIZE);
|
&log[i * SHELL_GUI_XSIZE], SHELL_GUI_XSIZE);
|
||||||
}
|
}
|
||||||
memset(&log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE],
|
|
||||||
0, SHELL_GUI_XSIZE);
|
|
||||||
|
|
||||||
len = (unsigned char)strlen(str1);
|
if(str1[len1 - 1] == '\n') {
|
||||||
|
--len1;
|
||||||
|
}
|
||||||
|
if(str2[len2 - 1] == '\n') {
|
||||||
|
--len2;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(&log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE],
|
strncpy(&log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE],
|
||||||
str1, SHELL_GUI_XSIZE);
|
str1, SHELL_GUI_XSIZE);
|
||||||
if(len < SHELL_GUI_XSIZE) {
|
if(len1 < SHELL_GUI_XSIZE) {
|
||||||
strncpy(&log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE] + len,
|
strncpy(&log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE] + len1,
|
||||||
str2, SHELL_GUI_XSIZE - len);
|
str2, SHELL_GUI_XSIZE - len1);
|
||||||
|
if(len1 + len2 < SHELL_GUI_XSIZE) {
|
||||||
|
log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE + len1 + len2] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CTK_WIDGET_REDRAW(&loglabel);
|
CTK_WIDGET_REDRAW(&loglabel);
|
||||||
@ -102,12 +110,10 @@ shell_output(char *str1, char *str2)
|
|||||||
void
|
void
|
||||||
shell_prompt(char *str)
|
shell_prompt(char *str)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
PROCESS_THREAD(shell_gui_process, ev, data)
|
PROCESS_THREAD(shell_gui_process, ev, data)
|
||||||
{
|
{
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
ctk_window_new(&window, SHELL_GUI_XSIZE,
|
ctk_window_new(&window, SHELL_GUI_XSIZE,
|
||||||
@ -117,19 +123,23 @@ PROCESS_THREAD(shell_gui_process, ev, data)
|
|||||||
CTK_WIDGET_ADD(&window, &commandentry);
|
CTK_WIDGET_ADD(&window, &commandentry);
|
||||||
/* CTK_WIDGET_SET_FLAG(&commandentry, CTK_WIDGET_FLAG_MONOSPACE);*/
|
/* CTK_WIDGET_SET_FLAG(&commandentry, CTK_WIDGET_FLAG_MONOSPACE);*/
|
||||||
CTK_WIDGET_FOCUS(&window, &commandentry);
|
CTK_WIDGET_FOCUS(&window, &commandentry);
|
||||||
memset(log, 0, sizeof(log));
|
|
||||||
|
|
||||||
shell_init();
|
shell_init();
|
||||||
|
shell_file_init();
|
||||||
|
shell_ps_init();
|
||||||
|
shell_text_init();
|
||||||
|
shell_time_init();
|
||||||
|
|
||||||
ctk_window_open(&window);
|
ctk_window_open(&window);
|
||||||
shell_start();
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
PROCESS_WAIT_EVENT();
|
PROCESS_WAIT_EVENT();
|
||||||
|
|
||||||
if(ev == ctk_signal_widget_activate &&
|
if(ev == ctk_signal_widget_activate &&
|
||||||
data == (process_data_t)&commandentry) {
|
data == (process_data_t)&commandentry) {
|
||||||
shell_output("> ", command);
|
int command_len = strlen(command);
|
||||||
shell_input(command);
|
shell_default_output("> ", 2, command, command_len);
|
||||||
|
shell_input(command, command_len);
|
||||||
if(shell_gui_process.state) {
|
if(shell_gui_process.state) {
|
||||||
CTK_TEXTENTRY_CLEAR(&commandentry);
|
CTK_TEXTENTRY_CLEAR(&commandentry);
|
||||||
CTK_WIDGET_REDRAW(&commandentry);
|
CTK_WIDGET_REDRAW(&commandentry);
|
||||||
@ -137,8 +147,6 @@ PROCESS_THREAD(shell_gui_process, ev, data)
|
|||||||
} else if(ev == ctk_signal_window_close ||
|
} else if(ev == ctk_signal_window_close ||
|
||||||
ev == PROCESS_EVENT_EXIT) {
|
ev == PROCESS_EVENT_EXIT) {
|
||||||
shell_quit(NULL);
|
shell_quit(NULL);
|
||||||
} else {
|
|
||||||
shell_eventhandler(ev, data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
|
Loading…
Reference in New Issue
Block a user