Beispiel #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;
}
Beispiel #2
0
int main(int argc, char **argv)
{
	int q, a, b;
	char cmd[32];

	scanf("%s %d", str, &q);
	while (q--) {
		scanf("%s %d %d", cmd, &a, &b);
		if (strcmp(cmd, "print") == 0) {
			cmd_p(a, b);
		} else if (strcmp(cmd, "reverse") == 0) {
			cmd_rev(a, b);
		} else {
			cmd_rplc(a, b);
		}
	}
	return 0;
}