34 #include "program-handler.h"
39 #include "ctk/ctk-textentry-cmdline.h"
43 #ifdef SHELL_GUI_CONF_XSIZE
44 #define SHELL_GUI_XSIZE SHELL_GUI_CONF_XSIZE
46 #define SHELL_GUI_XSIZE 10
49 #ifdef SHELL_GUI_CONF_YSIZE
50 #define SHELL_GUI_YSIZE SHELL_GUI_CONF_YSIZE
52 #define SHELL_GUI_YSIZE 10
56 static char log[SHELL_GUI_XSIZE * SHELL_GUI_YSIZE];
57 static struct ctk_label loglabel =
58 {
CTK_LABEL(0, 0, SHELL_GUI_XSIZE, SHELL_GUI_YSIZE, log)};
59 static char command[SHELL_GUI_XSIZE - 1];
60 static struct ctk_textentry commandentry =
61 {CTK_TEXTENTRY_INPUT(0, SHELL_GUI_YSIZE, SHELL_GUI_XSIZE - 2, 1, command,
62 SHELL_GUI_XSIZE - 2, ctk_textentry_cmdline_input)};
64 PROCESS(shell_gui_process,
"Command shell");
66 AUTOSTART_PROCESSES(&shell_gui_process);
72 static unsigned char i;
74 for(i = 1; i < SHELL_GUI_YSIZE; ++i) {
75 memcpy(&log[(i - 1) * SHELL_GUI_XSIZE],
76 &log[i * SHELL_GUI_XSIZE], SHELL_GUI_XSIZE);
79 if(str1[len1 - 1] ==
'\n') {
82 if(str2[len2 - 1] ==
'\n') {
86 strncpy(&log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE],
87 str1, SHELL_GUI_XSIZE);
88 if(len1 < SHELL_GUI_XSIZE) {
89 strncpy(&log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE] + len1,
90 str2, SHELL_GUI_XSIZE - len1);
91 if(len1 + len2 < SHELL_GUI_XSIZE) {
92 log[(SHELL_GUI_YSIZE - 1) * SHELL_GUI_XSIZE + len1 + len2] = 0;
115 SHELL_GUI_YSIZE + 1,
"Command shell");
136 data == (process_data_t)&commandentry) {
137 int command_len = (int)strlen(command);
140 if(shell_gui_process.state) {
145 ev == PROCESS_EVENT_EXIT) {
#define CTK_WIDGET_ADD(win, widg)
Add a widget to a window.
process_event_t ctk_signal_window_close
Emitted when a window is closed.
#define CTK_TEXTENTRY_CLEAR(e)
Clears a text entry widget and sets the cursor to the start of the text line.
void shell_prompt(char *str)
Print a prompt.
void ctk_window_open(CC_REGISTER_ARG struct ctk_window *w)
Open a window, or bring window to front if already open.
void shell_init(void)
Initialize the shell.
#define CTK_WIDGET_FOCUS(win, widg)
Set focus to a widget.
void ctk_window_close(struct ctk_window *w)
Close a window if it is open.
#define PROCESS_BEGIN()
Define the beginning of a process.
Main header file for the Contiki shell
void shell_input(char *commandline, int commandline_len)
Send a line of input to the shell.
void shell_quit(void)
Quit the shell.
#define CTK_LABEL(x, y, w, h, text)
Instantiating macro for the ctk_label widget.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
void ctk_window_new(struct ctk_window *window, unsigned char w, unsigned char h, char *title)
Create a new window.
#define LOADER_UNLOAD()
Unload a program from memory.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS(name, strname)
Declare a process.
process_event_t ctk_signal_widget_activate
Emitted when a widget is activated (pressed).
Representation of a CTK window.
void shell_default_output(const char *text1, int len1, const char *text2, int len2)
Print a line of output from the shell.
#define CTK_WIDGET_REDRAW(widg)
Add a widget to the redraw queue.
void shell_exit(void)
Request shell exit.
void process_exit(struct process *p)
Cause a process to exit.