Пример #1
0
int
editor_type::command (command_type& ct)
{
    static const std::wstring onemore (L"cdijkmnpstw"); 
    std::wstring doc;
    if (1 == ct.naddr)
        line2 = line1;
    if (line1 > line2 || buffer.dollar () < line1 || buffer.dollar () < line2)
        return '?';
    if (line1 == 0 && onemore.find (ct.command) != std::wstring::npos)
        return '?';
    switch (ct.command) {
    default: return '?';
    case 'a': ct.command = cmd_a (ct); break;
    case 'c': ct.command = cmd_c (ct); break;
    case 'd': ct.command = cmd_d (ct); break;
    case 'e': ct.command = cmd_e (ct); break;
    case 'f': ct.command = cmd_f (ct); break;
    case 'i': ct.command = cmd_i (ct); break;
    case 'j': ct.command = cmd_j (ct); break;
    case 'k': ct.command = cmd_k (ct); break;
    case 'm': ct.command = cmd_m (ct); break;
    case 'n': ct.command = cmd_n (ct); break;
    case 'p': ct.command = cmd_p (ct); break;
    case 'r': ct.command = cmd_r (ct); break;
    case 's': ct.command = cmd_s (ct); break;
    case 't': ct.command = cmd_t (ct); break;
    case 'w': ct.command = cmd_w (ct); break;
    case '=': ct.command = cmd_equal (ct); break;
    case '\n': ct.command = cmd_p (ct); break;
    }
    print_dot (ct);
    return ct.command;
}
Пример #2
0
static void cmd_r() {
	if(memu_state != END) { 
		char c;
		while(1) {
			printf("The program is already running. Restart the program? (y or n)");
			fflush(stdout);
			scanf(" %c", &c);
			switch(c) {
				case 'y': goto restart_;
				case 'n': return;
				default: puts("Please answer y or n.");
			}
		}
	}

restart_:
	restart();
	memu_state = STOP;
	cmd_c();
}