Changeset 2358


Ignore:
Timestamp:
06/11/08 17:45:02 (5 years ago)
Author:
jylam
Message:
  • Added a default shell roolback if no arguments are givent
  • ctrl-a-c adds a new screen
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/main.c

    r2357 r2358  
    4444    static caca_display_t *dp; 
    4545    struct screen_list *screen_list = NULL; 
    46     int pty = 0, prevpty = 0, i, w, h, nt; 
     46    char *default_shell = NULL; 
     47    int pty = 0, prevpty = 0, i, w, h, nt, args = 0; 
    4748    int eof = 0, refresh = 1, command = 0, mini = 1; 
    4849 
    49     if(argc < 2) 
    50     { 
    51         fprintf(stderr, "usage: %s <cmd1> [<cmd2> [<cmd3> ...]]\n", argv[0]); 
    52         fprintf(stderr, "eg. \"%s zsh bash\"\n", argv[0]); 
    53         return 1; 
    54     } 
    55  
    5650    nt = argc - 1; 
     51    args = nt; 
     52 
     53    if(nt == 0) 
     54    { 
     55        nt = 1; 
     56    } 
     57    default_shell = getenv("SHELL"); 
     58 
    5759 
    5860    /* Create main canvas and associated caca window */ 
     
    7880    for(i = 0; i < nt; i++) 
    7981    { 
    80         struct screen *tmp = create_screen(w, h, argv[i + 1]); 
     82        struct screen *tmp; 
     83        if(args) tmp = create_screen(w, h, argv[i + 1]); 
     84        else     tmp = create_screen(w, h, default_shell); 
     85 
    8186        if(tmp) 
    8287        { 
     
    215220                    prevpty = pty; 
    216221                    pty = (pty + screen_list->count - 1) % screen_list->count; 
     222                    refresh = 1; 
     223                    break; 
     224                case 0x03: //CACA_KEY_CTRL_C: 
     225                    prevpty = pty; 
     226                    pty = add_screen(screen_list, create_screen(w, h, default_shell)); 
    217227                    refresh = 1; 
    218228                    break; 
     
    276286                           j * YTAB + 1, screen_list->screen[j]->cv, NULL); 
    277287                cucul_draw_cp437_box(cv, (n - 1 - j) * XTAB, j * YTAB, 
    278                                      w + (n - 1 - j) * XTAB + 1, h + j * YTAB + 1); 
     288                                     w + (n - 1 - j) * XTAB + 1, h + j * YTAB + 2); 
    279289                /* Set cursor to the correct position */ 
    280290                if(i == n - 1) 
Note: See TracChangeset for help on using the changeset viewer.