示例#1
0
文件: shell.c 项目: kjk/qemacs
void shell_write_char(EditState *e, int c)
{
    char ch;

    if (e->interactive) {
        ShellState *s = e->b->priv_data;

        ch = c;
        tty_write(s, &ch, 1);
    } else {
        switch (c) {
        case 4:
            do_delete_char(e);
            break;
        case 9:
            do_tab(e);
            break;
        case 11:
            do_kill_region(e, 2);
            break;
        case 127:
            do_backspace(e);
            break;
        case '\r':
            do_return(e);
            break;
        default:
            text_write_char(e, c);
            break;
        }
    }
}
示例#2
0
void hexedit_driver(struct hexedit *buf, int c)
{
	switch (c) {
	case HE_CURSOR_UP:
		cursor_up(buf);
		break;
	case HE_CURSOR_DOWN:
		cursor_down(buf);
		break;
	case HE_CURSOR_LEFT:
		cursor_left(buf);
		break;
	case HE_CURSOR_RIGHT:
		cursor_right(buf);
		break;
	case HE_CURSOR_PGUP:
		break;
	case HE_CURSOR_PGDN:
		break;
	case HE_BACKSPACE:
		do_backspace(buf);
		break;
	case HE_DELETE:
		do_delete(buf);
		break;
	default:
		do_edit(buf, c & 0xff);
		break;
	}

	hexedit_set_cursor(buf);
}
示例#3
0
文件: prompt.c 项目: ris21/yoda
int do_dictionary_prompt(bool all, const char *msg, char *str)
{
    s_list l;
    s_node *p;
    int ok = -2, width = 16;
    const char *yesstr;		/* String of Yes characters accepted. */
    const char *nostr;		/* Same for No. */
    const char *allstr;		/* And All, surprise! */
    int u;
    char **thisarray = (char **)malloc(sizeof(char)*5);
	for(u = 0; u < 5; u++)
		thisarray[u] = (char *)malloc(sizeof(char)*16);
    thisarray = thisfunc(str);
    int oldmenu = currmenu;
    char but[16];
    int i, j = 0;
    int count = 0;
    int t = 0;
    int bs = 0;
    char buf[16];
    strcpy(buf, str);
    int tp;
    int we = 0, wc = 0;
    
    tp = typepos();
    
    assert(msg != NULL);
    
    s_init(&l);
    u = 0;
    while(u < 5) {
	s_append(&l, thisarray[u]);
	u++;
    }
    /*Now partial matched list is prepared*/
           p = l.head;
           

    if(str == NULL){
 
        count = 0;

        
        while(p){
            count++;
            p = p->next;
        }
    }
    
    //count=5;

    p = l.head;


    do {
	int kbinput;
	functionptrtype func;
        i = 0;
#ifndef DISABLE_MOUSE
	int mouse_x, mouse_y;
#endif

	if (!ISSET(NO_HELP)) {
	    char shortstr[3];
		/* Temporary string for (translated) " Y", " N" and " A". */

	    if (COLS < 32)
		width = COLS / 2;

	    /* Clear the shortcut list from the bottom of the screen. */
	    blank_bottombars();

	    /* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */


	    if (all) {
		shortstr[1] = allstr[0];
		wmove(bottomwin, 1, width);
		onekey(shortstr, _("All"), width);
	    }

            for(i = 0; i < count && i < 5; i++){
                sprintf(but, "%d", i + 1);
                if(i == 0) wmove(bottomwin, 1, 0);
                else wmove(bottomwin, 1, i * width);
                if(p){
                    onekey(but, p->word, width);
                    p = p->next;
                }
                j++;
            }

	    wmove(bottomwin, 1, i * width);
	    onekey("^C", _("Cancel"), width);
	}

	if (interface_color_pair[TITLE_BAR].bright)
	    wattron(bottomwin, A_BOLD);
	wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);

	blank_statusbar();
	mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));

	wattroff(bottomwin, A_BOLD);
	wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);

	/* Refresh edit window and statusbar before getting input. */
	wnoutrefresh(edit);
	wnoutrefresh(bottomwin);

	currmenu = MYESNO;
	kbinput = get_kbinput(bottomwin);

#ifndef NANO_TINY
	if (kbinput == KEY_WINCH)
	    continue;
#endif
        /*49 is 1, 50 is 2 and so on*/

	func = func_from_key(&kbinput);

	if (func == do_cancel){
	    ok = 0;
            return ok;
        }
  
        if(kbinput == 's'){
            if(i == 5) {
                continue;
            }
        }
        if(kbinput <= '0' || kbinput > '0' + count) return -1;
        
        if(kbinput > '0' && kbinput <= '0' + count){
            p = l.head;
            i = kbinput - '0' - 1;
            if(j > 5) t = j - 5 + i;
            else t = i;

            while(t--) if(p){
                        p = p->next;
                        }
            
            if(tp == 1 || tp == 2){
                bs = strlen(str);
                while(bs--) do_backspace();
            }
            

            if(tp == 6 || tp == 7){
                if(str != NULL){


                    we = openfile->current_x;

                    while(openfile->current->data[we] != ' ' && openfile->current->data[we] != '\00'){
                     we++;
                        wc++;
                        do_right();
                    }

                    we--;
                    while(openfile->current->data[we] != ' ' && openfile->current->data[we] != '\00'){

                        do_backspace();
                        we--;
                    }
                }
            }
            
            
            do_output(p->word, strlen(p->word), FALSE);
            return tp;
        }


	else if (func == total_refresh) {
	    total_redraw();
	    continue;
	} else {
		/* Look for the kbinput in the Yes, No and (optionally)
		 * All strings. */
		if (strchr(yesstr, kbinput) != NULL)
		    ok = 1;
		else if (strchr(nostr, kbinput) != NULL)
		    ok = 0;
		else if (all && strchr(allstr, kbinput) != NULL)
		    ok = 2;
	}
        i = 0;
        p = l.head;
        
    } while (ok == -2);

    currmenu = oldmenu;
    return ok;
}