diff --git a/README.OSX b/README.OSX index 1ad536ce..2dc5473c 100644 --- a/README.OSX +++ b/README.OSX @@ -73,6 +73,10 @@ from a Terminal (X11 Terminal in case of GTK2 interface) type: $ freej [enter] and you should see. +in case you want to have a colorful command console on your terminal, +before starting freej you can type 'screen' (enter), this will start +a console manager which fully supports ANSI colors (see 'man screen'). + ================================== Appendix.1 : open the Terminal diff --git a/TODO b/TODO index a8bc33f3..5e0d3d63 100644 --- a/TODO +++ b/TODO @@ -1,25 +1,30 @@ +**** FIX per la 0.7: + - console backspace + - magnify + - completion per open layer + + $Id$ *** cairo layers: poligons and svg *** libvisual layer - *** finalize JavaScript API + *** 8bit geometrical mask blits - *** finish the Iterator class + *** filebrowser in SDL + + *** complete the Iterator class *** Quicktime video layer for Darwin/OSX *** LiViDO shared plugin library - *** geometrical 8bit masks for blits - *** Open Sound Control for remote interoperability *** enhance text layer (more scrollers, word positioning etc.) - *** XScreensaver layer // must PORT screenhacks code :( HINT from salsaman: diff --git a/src/console.cpp b/src/console.cpp index 0e81fbaa..db79ac02 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -40,6 +40,7 @@ #define KEY_ENTER 13 #define KEY_SPACE 32 #define KEY_BACKSPACE 275 +#define KEY_BACKSPACE_APPLE 127 #define KEY_LEFT 259 #define KEY_RIGHT 260 #define KEY_HOME 263 @@ -147,7 +148,7 @@ static int blit_comp(char *cmd) { if(!blits[1]) { // exact match, then fill in command b = (Blit*) lay->blitter.blitlist.pick(blits[0]); ::notice("%s :: %s",b->get_name(),b->desc); - snprintf(cmd,511,"%s",b->get_name()); + snprintf(cmd,MAX_CMDLINE,"%s",b->get_name()); return 1; } @@ -284,9 +285,75 @@ static int open_text_layer(char *cmd) { } #endif +#include +static char *path = NULL; +static int filebrowse_completion_selector(const struct dirent *dir) { + if(dir->d_name[0]=='.') + if(dir->d_name[1]!='.') + return(0); // skip hidden files + return(1); +} static int filebrowse_completion(char *cmd) { - func("filebrowser completion TODO"); - return(0); + Linklist files; + Entry *e; + struct dirent **filelist; + int *comps; + int found; + int c; + + if(!path) { + path = (char*)calloc(MAX_CMDLINE,sizeof(char)); + strncpy(path,getenv("PWD"),MAX_CMDLINE); + } + + found = scandir(path,&filelist, + filebrowse_completion_selector,alphasort); + + if(found<0) { + error("filebrowse_completion: scandir: %s",strerror(errno)); + return 0; + } + + for(c=found-1;c>0;c--) { // insert each entry found in a linklist + e = new Entry(); + e->set_name(filelist[c]->d_name); + files.append(e); + } + + comps = files.completion(cmd); + if(comps[0]) { // something found + + if(!comps[1]) { // exact match + e = files.pick(comps[0]); + DIR *d = opendir( e->name ); + if(d) { // is a directory + closedir(d); + snprintf(path,MAX_CMDLINE,"%s/%s",path,e->name); + } + strncpy(cmd,e->name,MAX_CMDLINE); + + c = 1; + + } else { // multiple matches + + for(c=0;comps[c];c++) { + e = files.pick(comps[c]); + ::act("%s",e->name); + } + + } + + } else c = 0; + + // free entries allocated in memory + e = files.begin(); + while(e) { + files.rem(1); + delete e; + e = files.begin(); + } + + return(c); } static int set_blit_value(char *cmd) { @@ -417,7 +484,7 @@ int Console::readline(char *msg,cmd_process_t *proc,cmd_complete_t *comp) { SLsmg_erase_eol(); cursor = 0; - memset(command,EOL,512); + memset(command,EOL,MAX_CMDLINE); SLtt_set_cursor_visibility(1); cmd_process = proc; @@ -1153,7 +1220,7 @@ void Console::parser_commandline(int key) { commandline = true; // don't print statusline /* =============== console command input */ - if(cursor>512) { + if(cursor>MAX_CMDLINE) { error("command too long, can't type more."); return; } @@ -1166,7 +1233,6 @@ void Console::parser_commandline(int key) { case KEY_ENTER: // a blank commandline aborts the input if(command[0]==EOL) { - func("command aborted"); parser = DEFAULT; cmd_process = NULL; cmd_complete = NULL; @@ -1197,7 +1263,7 @@ void Console::parser_commandline(int key) { else entr = entr->prev; if(!entr) return; // no hist - strncpy(command,(char*)entr->data,512); + strncpy(command,(char*)entr->data,MAX_CMDLINE); // type the command on the console SLsmg_gotorc(SLtt_Screen_Rows - 1,1); SLsmg_write_string(command); @@ -1211,7 +1277,7 @@ void Console::parser_commandline(int key) { if(!entr) return; if(!entr->next) return; entr = entr->next; - strncpy(command,(char*)entr->data,512); + strncpy(command,(char*)entr->data,MAX_CMDLINE); // type the command on the console SLsmg_gotorc(SLtt_Screen_Rows - 1,1); SLsmg_write_string(command); @@ -1242,25 +1308,30 @@ void Console::parser_commandline(int key) { return; - case KEY_BACKSPACE: /*** FIXME */ + case KEY_BACKSPACE: + case KEY_BACKSPACE_APPLE: if(!cursor) return; - cursor--; - if(command[cursor+1]==EOL) { - // func("cursor on end of line"); - command[cursor] = EOL; - } else { - for(c=cursor;command[c]!=EOL;c++) - command[c] = command[c+1]; - command[c] = EOL; - SLsmg_write_string(&command[cursor]); + + for(c=cursor;ccursor;c--) + command[c] = command[c-1]; // move backwards switching right + + command[cursor] = key; // insert new char + + // GOTO_CURSOR; SLsmg_write_string(&command[cursor]); SLsmg_erase_eol(); cursor++; GOTO_CURSOR; + } diff --git a/src/include/console.h b/src/include/console.h index 145a7e92..22323cb4 100644 --- a/src/include/console.h +++ b/src/include/console.h @@ -25,6 +25,7 @@ #include #include +#define MAX_CMDLINE 256 /* The SLscroll routines will use this structure. */ typedef struct _File_Line_Type { @@ -97,7 +98,7 @@ class Console { /* input console command */ bool commandline; int cursor; - char command[512]; + char command[MAX_CMDLINE]; cmd_process_t *cmd_process; cmd_complete_t *cmd_complete;