/** * @brief adss callback for given input * @param[in] cbwrapper - callback wrapper to trigger on input * @param[in] input - the input to trigger callback */ void todo_edit_base::callback(int input) { switch(input) { case CMDK_ARROW_LEFT: if(m_cursor_pos > 1) m_cursor_pos--; break; case CMDK_ARROW_RIGHT: if(m_cursor_pos < m_text.length()) m_cursor_pos++; break; case CMDK_DELETE: del_char(true); break; case CMDK_BACKSPACE: del_char(false); break; default: if(is_valid(input)) add_char(input & 0xFF); break; } // trigger callback if set if(m_callbacks[input]) m_callbacks[input]->callback_wrapper(m_callbacks[input]->params); if(m_callbacks[TD_EDIT_TRIGGERED_CB]) m_callbacks[TD_EDIT_TRIGGERED_CB]->callback_wrapper(m_callbacks[TD_EDIT_TRIGGERED_CB]->params); }
int do_inputline(Input *inputline, int c, int alt) { switch (c) { case KEY_ENTER: case '\n': case '\r': if (!alt) inputline->finish(inputline); break; case KEY_DC: if (del_char(inputline, 0)) inputline->update(inputline); break; case KEY_BACKSPACE: if (del_char(inputline, 1)) inputline->update(inputline); break; case KEY_LEFT: if ((inputline->len > 0) && (inputline->pos > 1)) { inputline->pos--; inputline->update(inputline); } break; case KEY_RIGHT: if (inputline->pos <= inputline->len) { inputline->pos++; inputline->update(inputline); } break; case KEY_HOME: inputline->pos = 1; inputline->update(inputline); break; case KEY_END: inputline->pos = inputline->len + 1; inputline->update(inputline); break; case '\t': if (inputline->complete && inputline->complete(inputline)) inputline->update(inputline); default: if (add_char(inputline, c)) inputline->update(inputline); break; } return 1; }
int main(int argc, const char *argv[]) { char str[] = "Linux c and GCC"; printf("Please input the char to delete"); char ch = getchar(); getchar(); del_char(str,ch); puts(str); return 0; }
/* Our window with cursor has got some input key_cnt == -1 means no input has been taking place at this cursor position key_cnt >= 0 means the same key has been pressed one or more times here */ void win_cursor_input(int new_key){ char c; if (new_key == CURSOR_LEFT){ dec_cursor(); key_cnt = -1; last_key = -1; timer_stop(&char_tmr); return; }; if (new_key == CURSOR_RIGHT){ advance_cursor(); key_cnt = -1; last_key = -1; timer_stop(&char_tmr); return; }; /* A bit tricky. It makes sense to implement this as a kind of delete, i.e. delete the character under the cursor. This only fails if the cursor is at end of text. Then delete the last character. */ if (new_key == CURSOR_BACKSPACE){ key_cnt = -1; last_key = -1; timer_stop(&char_tmr); del_char(pcursor_win, cursor_pos); cursor_pos = min(cursor_pos, pcursor_win->text_len); return; }; timer_set(&char_tmr, WAIT_KEY_TIME, 0); // start auto advance timer /* This is the first time a key is pressed here */ if (key_cnt < 0){ key_cnt = 0; c = key2char(new_key, 0); store_char(pcursor_win, cursor_pos, c); } else { /* We already entered text at this cursor position */ if (new_key == last_key){ // User pressed the same key twice before a time out occured key_cnt++; c = key2char(new_key, key_cnt); store_char(pcursor_win, cursor_pos, c); } else { // User pressed a different key, advance to the next cursor position, store new char key_cnt = 0; c = key2char(new_key, 0); advance_cursor(); store_char(pcursor_win, cursor_pos, c); }; }; last_key = new_key; };
void compose_handle_keypress(uint8_t key) { if (state_ == COMPOSE_STATE_WRITING) { switch (key) { case KBACK: del_char(); compose_draw(); break; case '<': cursor_left(); compose_draw(); break; case '>': cursor_right(); compose_draw(); break; case ' ': case ',': add_char(key); compose_draw(); break; case KALT: alt_on_ = !alt_on_; compose_draw(); break; case KSPK: if (alt_on_) { add_char('0'); compose_draw(); } break; case '\n': state_ = COMPOSE_STATE_CONFIRM; compose_draw(); default: if (key >= 'A' && key <= 'Z') { add_char(key); compose_draw(); } break; } } else if (state_ == COMPOSE_STATE_CONFIRM) { switch (key) { case 'Y': state_ = COMPOSE_STATE_SENDING; compose_draw(); send_message(); break; case 'N': state_ = COMPOSE_STATE_WRITING; compose_draw(); break; } } }
// clean \r and \n from a string // returns 1 if changes were made int clean_carrier(char * string) { int i, changes = 0, len = strlen(string); for (i=0; i<len; i++) { if ( string[i] == '\r' || string[i] == '\n' ) { del_char(string, i); len--; changes = 1; } } return changes; }
PLine Line::split(int split_pos, Buffer* pBuf) { if(split_pos < 0) return 0; PLine ln = new Line(this); del_char(split_pos, len(), pBuf); ln->del_char(0, split_pos); return ln; }
int main(void) { char ch, c, str[1000]; scanf("%c", &ch); c = getchar(); gets(str); del_char(ch, str); return 0; }
static el_status_t meta(void) { int c; el_keymap_t *kp; if ((c = tty_get()) == EOF) return CSeof; #ifdef CONFIG_ANSI_ARROWS /* Also include VT-100 arrows. */ if (c == '[' || c == 'O') { switch (tty_get()) { case EOF: return CSeof; case '2': tty_get(); return CSstay; /* Insert */ case '3': tty_get(); return del_char(); /* Delete */ case '5': tty_get(); return CSstay; /* PgUp */ case '6': tty_get(); return CSstay; /* PgDn */ case 'A': return h_prev(); /* Up */ case 'B': return h_next(); /* Down */ case 'C': return fd_char(); /* Left */ case 'D': return bk_char(); /* Right */ case 'F': return end_line(); /* End */ case 'H': return beg_line(); /* Home */ default: /* Fall through */ break; } return el_ring_bell(); } #endif /* CONFIG_ANSI_ARROWS */ if (isdigit(c)) { for (Repeat = c - '0'; (c = tty_get()) != EOF && isdigit(c); ) Repeat = Repeat * 10 + c - '0'; tty_push(c); return CSstay; } if (isupper(c)) return do_macro(c); for (kp = MetaMap; kp->Function; kp++) { if (kp->Key == c) return kp->Function(); } return el_ring_bell(); }
char *ft_strdelchar(char *str, char c) { size_t i; char *tmp; i = 0; if (!c || !str) return (NULL); tmp = malloc(sizeof(char*) * ft_strlen(str)); tmp = ft_strcpy(tmp, str); while (str[i]) { if (str[i] == c) tmp = del_char(str, c); i++; } return (tmp); }
MDS_DATA BufferMsgProc(void *obj, int message, MDS_DATA extra_data) { Buffer *buffer = (Buffer *)obj; if (!buffer->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 con_gotoXY(buffer->pos.x, buffer->pos.y); if (extra_data.integer == -1) { con_outTxt("%*s", buffer->size.x, ""); } else { if (buffer->active) con_outTxt("<%*s>", buffer->text_len, buffer->text); else con_outTxt("[%*s]", buffer->text_len, buffer->text); } break; case MESSAGE_MOVE: move_object((Object *)buffer, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)buffer, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: if (!process_keys((Object *)buffer, extra_data.integer)) { if (extra_data.integer >= 32 && extra_data.integer <= 255) add_char(buffer, extra_data.integer); else if (extra_data.integer == CON_KEY_BACKSPACE) del_char(buffer); } break; } return NULL_DATA; }
t_termc *epure_path(t_termc *new_com) { t_termc *to_check; t_com *buff; t_com *buff2; to_check = init_char_list(); buff = new_com->end; while (buff && buff->c != '/') buff = buff->prev; if (buff) buff = buff->next; else return (new_com); while (buff) { char_to_list(to_check, buff->c); buff2 = buff; buff = buff->next; del_char(new_com, buff2); } return (to_check); }
int main (void) { char x, y, a; ioinit(); //Setup IO pins and defaults USART_Init( MYUBRR); rprintf_devopen(put_char); /* init rrprintf */ //reset the display delay_ms(1); PORTC |= (1<<RST); //initialize the display display_init(); clear_screen(); //Backlight on PORTB &= (~(1<<BL_EN)); while(1) { if(RX_in != RX_read) { x = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; //Backspace=================================================== if(x == 8) del_char(0); //Special commands else if (x == 124) { //make sure the next byte is there while(RX_in == RX_read); //0, clear screen====================================================== if(RX_array[RX_read] == 0) { clear_screen(); RX_read++; if(RX_read >= 256) RX_read = 0; } //Backlight on/off else if(RX_array[RX_read] == 2) { y = PINB; if (y & (1<<BL_EN)) PORTB &= (~(1<<BL_EN)); else PORTB |= (1<<BL_EN); RX_read++; } //demo mode else if(RX_array[RX_read] == 4) { RX_in = 0, RX_read = 0; demo(); clear_screen(); RX_in = 0; } else { //set x or y========================================================= if((RX_array[RX_read] == 24) | (RX_array[RX_read] == 25)) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte if (RX_array[RX_read-1] == 24) x_offset = RX_array[RX_read]; else if (RX_array[RX_read-1] == 25) y_offset = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; if (x_offset > 159) x_offset = 159; if (y_offset > 127) y_offset = 127; } //set pixel========================================================= if (RX_array[RX_read] == 16) { //need 3 bytes for (y = 0; y < 3; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } pixel(RX_array[RX_read], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>c, circle====================================================== if(RX_array[RX_read] == 3) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } circle(RX_array[RX_read], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>e, erase block====================================================== if(RX_array[RX_read] == 5) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } erase_block(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>o, box, running out of meaningful letters====================================================== if(RX_array[RX_read] == 15) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } box(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>L, line======================================================== else if (RX_array[RX_read] == 12) { //need 5 bytes for (y = 0; y < 5; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } line(RX_array[RX_read], RX_array[RX_read-4], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read+-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } } } //print character to the screen=============================================== else { del_char(1); print_char(1, x); } } } }
static void handle_ansi(u8_t byte, char *line) { if (atomic_test_and_clear_bit(&esc_state, ESC_ANSI_FIRST)) { if (!isdigit(byte)) { ansi_val = 1; goto ansi_cmd; } atomic_set_bit(&esc_state, ESC_ANSI_VAL); ansi_val = byte - '0'; ansi_val_2 = 0; return; } if (atomic_test_bit(&esc_state, ESC_ANSI_VAL)) { if (isdigit(byte)) { if (atomic_test_bit(&esc_state, ESC_ANSI_VAL_2)) { ansi_val_2 *= 10; ansi_val_2 += byte - '0'; } else { ansi_val *= 10; ansi_val += byte - '0'; } return; } /* Multi value sequence, e.g. Esc[Line;ColumnH */ if (byte == ';' && !atomic_test_and_set_bit(&esc_state, ESC_ANSI_VAL_2)) { return; } atomic_clear_bit(&esc_state, ESC_ANSI_VAL); atomic_clear_bit(&esc_state, ESC_ANSI_VAL_2); } ansi_cmd: switch (byte) { case ANSI_BACKWARD: if (ansi_val > cur) { break; } end += ansi_val; cur -= ansi_val; cursor_backward(ansi_val); break; case ANSI_FORWARD: if (ansi_val > end) { break; } end -= ansi_val; cur += ansi_val; cursor_forward(ansi_val); break; case ANSI_HOME: if (!cur) { break; } cursor_backward(cur); end += cur; cur = 0; break; case ANSI_END: if (!end) { break; } cursor_forward(end); cur += end; end = 0; break; case ANSI_DEL: if (!end) { break; } cursor_forward(1); del_char(&line[cur], --end); break; default: break; } atomic_clear_bit(&esc_state, ESC_ANSI); }
void uart_console_isr(struct device *unused) { ARG_UNUSED(unused); while (uart_irq_update(uart_console_dev) && uart_irq_is_pending(uart_console_dev)) { static struct console_input *cmd; u8_t byte; int rx; if (!uart_irq_rx_ready(uart_console_dev)) { continue; } /* Character(s) have been received */ rx = read_uart(uart_console_dev, &byte, 1); if (rx < 0) { return; } #ifdef CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS if (debug_hook_in != NULL && debug_hook_in(byte) != 0) { /* * The input hook indicates that no further processing * should be done by this handler. */ return; } #endif if (!cmd) { cmd = k_fifo_get(avail_queue, K_NO_WAIT); if (!cmd) { return; } } #ifdef CONFIG_UART_CONSOLE_MCUMGR /* Divert this byte from normal console handling if it is part * of an mcumgr frame. */ if (handle_mcumgr(cmd, byte)) { continue; } #endif /* CONFIG_UART_CONSOLE_MCUMGR */ /* Handle ANSI escape mode */ if (atomic_test_bit(&esc_state, ESC_ANSI)) { handle_ansi(byte, cmd->line); continue; } /* Handle escape mode */ if (atomic_test_and_clear_bit(&esc_state, ESC_ESC)) { if (byte == ANSI_ESC) { atomic_set_bit(&esc_state, ESC_ANSI); atomic_set_bit(&esc_state, ESC_ANSI_FIRST); } continue; } /* Handle special control characters */ if (!isprint(byte)) { switch (byte) { case DEL: if (cur > 0) { del_char(&cmd->line[--cur], end); } break; case ESC: atomic_set_bit(&esc_state, ESC_ESC); break; case '\r': cmd->line[cur + end] = '\0'; uart_poll_out(uart_console_dev, '\r'); uart_poll_out(uart_console_dev, '\n'); cur = 0; end = 0; k_fifo_put(lines_queue, cmd); cmd = NULL; break; case '\t': if (completion_cb && !end) { cur += completion_cb(cmd->line, cur); } break; default: break; } continue; } /* Ignore characters if there's no more buffer space */ if (cur + end < sizeof(cmd->line) - 1) { insert_char(&cmd->line[cur++], byte, end); } } }
int main (void) { char x, y; //char a = 0; ioinit(); //Setup IO pins and defaults USART_Init( MYUBRR); rprintf_devopen(put_char); /* init rrprintf */ //set_data(0x55); //PORTC |= ((1 << RESET) | (1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2) | (1 << RS));//all high //while(1); /* while(1) { PORTC &= ~((1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2));//down delay_ms(500); //PORTC |= ((1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2));//all high PORTC |= ((1 << RESET) | (1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2) | (1 << RS));//all high delay_ms(500); } */ /* DDRC = 0b00000001; while(1) { PORTC |= 0b00000001; delay_1uS(); PORTC &= 0b11111110; delay_1uS(); } */ //Reset the display //PORTC = 0b11110111; PORTC &= ~(1 << RESET); delay_ms(50); PORTC |= (1 << RESET); delay_ms(500); clear_screen(); set_page(0); set_x(0); display_on(); //set display start line to 0 //set control lines PORTC &= ~((1 << EN) | (1 << R_W) | (1 << RS));//down set_port_out(); //set_data(0xC0); set_data(0xC0); delay_us(4); PORTC |= (1 << EN);//up delay_us(4); PORTC &= ~(1 << EN);//down delay_us(4); PORTC |= ((1 << EN) | (1 << R_W) | (1 << RS));//all high set_port_in(); delay_us(4); x_offset = 0; set_page(0); //Backlight on PORTB &= (~(1<<BL_EN)); //demo(); //put_char('X'); while(1) { if(RX_in != RX_read) { x = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; //Backspace=================================================== if(x == 8) del_char(0); //Special commands else if (x == 124) { //make sure the next byte is there while(RX_in == RX_read); //0, clear screen====================================================== if(RX_array[RX_read] == 0) { clear_screen(); RX_read++; if(RX_read >= 256) RX_read = 0; } //Backlight on/off else if(RX_array[RX_read] == 2) { y = PINB; if (y & (1<<BL_EN)) PORTB &= (~(1<<BL_EN)); else PORTB |= (1<<BL_EN); RX_read++; } //demo mode else if(RX_array[RX_read] == 4) { RX_in = 0, RX_read = 0; demo(); clear_screen(); RX_in = 0; } else { //set x or y========================================================= if((RX_array[RX_read] == 24) | (RX_array[RX_read] == 25)) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte if (RX_array[RX_read-1] == 24) x_offset = RX_array[RX_read]; else if (RX_array[RX_read-1] == 25) y_offset = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; if (x_offset > 127) x_offset = 127; if (y_offset > 63) y_offset = 63; } //set pixel========================================================= if (RX_array[RX_read] == 16) { //need 3 bytes for (y = 0; y < 3; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } pixel(RX_array[RX_read], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>c, circle====================================================== if(RX_array[RX_read] == 3) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } circle(RX_array[RX_read], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>e, erase block====================================================== if(RX_array[RX_read] == 5) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } erase_block(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>o, box, running out of meaningful letters====================================================== if(RX_array[RX_read] == 15) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } box(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>L, line======================================================== else if (RX_array[RX_read] == 12) { //need 5 bytes for (y = 0; y < 5; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } line(RX_array[RX_read], RX_array[RX_read-4], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read+-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } } } //print character to the screen=============================================== else { del_char(1); //put_char('L'); print_char(1, x); } //set_data(0xFF); //set_port_in(); //display_on(); //y = PINB; //PORTB = y; } } }
void title_handle_key_evt (struct android_app* app, AInputEvent* event) { Context* context = (Context*) app->userData; int32_t key_code, i; if (AKeyEvent_getAction(event) != AKEY_EVENT_ACTION_UP) { return; } key_code = AKeyEvent_getKeyCode(event); switch (context->title->state) { case TITLE_STATE_LOAD_PROFILE: if (key_code == AKEY_CODE_BACK) { title_transition(context, TITLE_STATE_MAIN); } break; case TITLE_STATE_NEW_PROFILE: if (key_code == AKEY_CODE_BACK) { title_transition(context, TITLE_STATE_MAIN); } else if ( key_code >= AKEY_CODE_A && key_code <= AKEY_CODE_Z && ( context->title->profile_name == NULL || strlen(context->title->profile_name) <= PROFILE_MAX_LEN ) ) { char c = key_code - AKEY_CODE_A + 'A'; if (context->title->profile_name == NULL) { context->title->profile_name = (char*) malloc((PROFILE_MAX_LEN + 1) * sizeof(char)); context->title->profile_line = (Line*) malloc(sizeof(Line)); context->title->profile_line->v_bufs = (vertex_buffer**) malloc(PROFILE_MAX_LEN * sizeof(vertex_buffer*)); context->title->profile_line->x = 0; context->title->profile_line->y = SCREEN_TOP + GLYPH_SIZE + LINE_GAP; context->title->profile_line->len = 0; context->title->profile_name[0] = c; context->title->profile_name[1] = '\0'; } else { context->title->profile_name[ context->title->profile_line->len ] = c; context->title->profile_name[ context->title->profile_line->len+1 ] = '\0'; } write_char(context->glyphs, context->title->profile_line, c); } else if (key_code == AKEY_CODE_DEL) { if (context->title->profile_name == NULL) { return; } if (context->title->lines[1] != NULL) { del_line(context->glyphs, context->title->lines[1]); } if (strlen(context->title->profile_name) == 1) { free(context->title->profile_name); context->title->profile_name = NULL; del_line(context->glyphs, context->title->profile_line); } else { del_char(context->glyphs, context->title->profile_line); context->title->profile_name[ context->title->profile_line->len ] = '\0'; } } else if (key_code == AKEY_CODE_ENTER) { int valid = 1; int idx = 0; for (i = 0; i < MAX_PROFILES; i++) { if (context->profiles[i] == NULL) { break; } if ( strcasecmp( context->profiles[i]->name , context->title->profile_name ) == 0 ) { valid = 0; } idx++; } if (!valid) { context->title->lines[1] = write_line( context->glyphs , 0 , SCREEN_TOP + (GLYPH_SIZE + LINE_GAP) * 3 , "Name in use" ); } else { context->profiles[i] = new_profile( context->app , context->title->profile_name , 0 , 0 ); context->profile = context->profiles[idx]; title_transition(context, TITLE_STATE_MAIN); } } break; } }
void readline(shell_struct *shell) { int i; int end = 0; /*stoppe la saisie lorsqu'il vaut 1*/ int cur_col = 0; /*dans le terminal, indique la position du pointeur*/ struct winsize ws; ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); int colonnes = ws.ws_col; cur_col = shellPrompt(0); fflush(stdout); printf("\033[s"); struct termios oldt; if (tcgetattr(0, &oldt) != 0) { perror("Erreur tcget"); } struct termios newt = oldt; cfmakeraw(&newt); /* On change la structure termios default, on ajout un retour chariot a chaque newline detecté */ //newt.c_oflag |= (ONLCR | OPOST); if (tcsetattr(0, TCSANOW, &newt) != 0) { perror("Erreur tcset"); } char *com_hist; int count = 0;/*sauvegarde le nombre de char dans le buffer*/ int pos = 0;/*position du curseur dans le buffer buf*/ /*variables pour la tabulation*/ struct tab tabu; init_tab(&tabu); shell->buf[count] = '\0'; do { int t, m; int c = getbigchar(); switch (c) { case 1: /*C^a*/ while (pos > 0) { move_left(&pos,&cur_col,colonnes); } break; case 3: /*C^c*/ shell->buf[0] = '\0'; break; case 4: /*C^D*/ shell->end_b = 1; end = 1; shell->buf[0] = '\n'; break; case 5: /*C^e*/ while (pos != count) { move_right(&pos,&cur_col,colonnes,count); } break; case 9:/*TAB autocompletion */ tabu.tab = 1; /*tab est pressé pour la première fois*/ if (tabu.noccur == 0){ /*on récupère le dernier mot*/ tabu.lw = lastword(shell->buf, &(shell->buf[pos]), &(tabu.after_com), ' '); /*on sauvegarde la position*/ tabu.save_pos = pos - strlen(tabu.lw); } /*on efface*/ while( pos > tabu.save_pos){ move_left(&pos,&cur_col,colonnes); del_char(&pos, &cur_col, colonnes, &count, shell); } ++tabu.noccur; tabu.suggest = look_up_command(tabu.lw, tabu.noccur, tabu.after_com); if (!strncmp(tabu.suggest, "",1)){ tabu.noccur = 1; tabu.suggest = tabu.lw; /*on reprend le mot de base*/ } /*on insère*/ i = 0; while (tabu.suggest[i] != '\0') { insert_char(&pos, &cur_col, colonnes, &count, shell, tabu.suggest[i]); i++; } break; case 11:/*^Ck*/ strncpy(shell->save_buf, &shell->buf[pos], count - pos); shell->save_buf[(count + 1) - pos] = '\0'; while(pos != count) { del_char(&pos,&cur_col,colonnes,&count,shell); } break; case 13:/*Enter*/ end = 1; while (pos != count) { move_right(&pos,&cur_col,colonnes,count); } strncmp(shell->buf, "\0", 1) ? insert_new_cmd(shell->buf) : 0; shell->buf[pos] = '\0'; break; case 25:/*C^y*/ i = 0; while (shell->save_buf[i] != '\0') { insert_char(&pos, &cur_col, colonnes, &count, shell, shell->save_buf[i]); i++; } break; case 2: /*C^b*/ case KLEFT: move_left(&pos, &cur_col, colonnes); break; case 6:/*C^f*/ case KRIGHT: move_right(&pos, &cur_col, colonnes, count); break; case KUP:/*historique -*/ if (!is_empty_hist()){ printf("\033[u"); printf("\033[K"); cur_col = shellPrompt(0); com_hist = get_prev_cmd(); printf("%s", com_hist); strncpy(shell->buf, com_hist, strlen(com_hist) + 1); cur_col += strlen(com_hist); count = strlen(com_hist); pos = count; } break; case KDOWN:/*historique +*/ if (!is_empty_hist()){ printf("\033[u"); printf("\033[K"); cur_col = shellPrompt(0); com_hist = get_next_cmd(); printf("%s", com_hist); strncpy(shell->buf, com_hist, strlen(com_hist) + 1); cur_col += strlen(com_hist); count = strlen(com_hist); pos = count; } break; case KDEL: /* Touche suppr */ del_char(&pos,&cur_col,colonnes,&count,shell); break; case 127: /* Touche retour (del) */ tabu.noccur = 0; if (pos == 0) { break; } if (pos < count) { for (i = pos - 1; i < count; i++) { shell->buf[i] = shell->buf[i + 1]; } } else { shell->buf[pos - 1] = '\0'; } if (cur_col > 0) { printf("\033[D"); cur_col--; } else { printf("\033[A\033[%dC", colonnes - 1); cur_col = colonnes - 1; } count--; pos--; printf("%s ", &shell->buf[pos]); t = count - pos + 1; m = (t + cur_col - 1) / colonnes; if (m > 0) { printf("\033[%dA", m); } t -= m * colonnes; if (t > 0) { printf("\033[%dD", t); } else if (t < 0) { printf("\033[%dC", -t); } break; default: if (tabu.tab){ tabu.noccur = 0; } insert_char(&pos, &cur_col, colonnes, &count, shell, c); break; } fflush(stdout); } while (!end); if (tcsetattr(0, TCSANOW, &oldt) != 0) { perror("erreur tcset"); } printf("\n"); }
int normal_mode_process(int key_down) { #ifdef __VIC_POSIX int second_key_down = 0; #endif char t[100]; sprintf(t, "%x", key_down); print_log(t); switch (key_down) { case '\x1b': //Esc #ifdef __VIC_POSIX second_key_down = getchar(); switch (second_key_down) //double stroke Esc to return to normal mode. { case '\x5b': second_key_down = getchar(); switch (second_key_down) { case '\x41': //up cursor_up(); break; case '\x42': //down cursor_down(); break; case '\x43': //right cursor_right(); break; case '\x44': //left cursor_left(); break; default: break; } break; default: break; } #endif #ifdef __VIC_WIN #endif break; #ifdef __VIC_WIN /* case '\xe0': //first(or last maybe?) ascii of arrow keys. case '\x00': switch (getch()) { case '\x48': //up cursor_up(); break; case '\x50': //down cursor_down(); break; case '\x4b': //left cursor_left(); break; case '\x4d': //right cursor_right(); break; default: break; } break; */ case '\x48': //up cursor_up(); break; case '\x50': //down cursor_down(); break; case '\x4b': //left cursor_left(); break; case '\x4d': //right cursor_right(); break; #endif case '!': //quit directly. enable_display_back(); set_cursor_pos(console_columns, console_lines); exit(0); break; case '1': //New File. case 'n': if (changed_flag == UNCHANGED || changed_flag == UNSAVED) { enable_display_back(); set_cursor_pos(console_columns, console_lines); } else { changed_flag = UNSAVED; } break; case 'q': //quit, is saved should be checked. if (changed_flag == UNCHANGED || changed_flag == UNSAVED) { enable_display_back(); set_cursor_pos(console_columns, console_lines); exit(0); } else { changed_flag = UNSAVED; } break; //belows hjkl for cursor moving. //aiming to disable moving cursor outside the file part. case 'h': cursor_left(); break; case 'l': cursor_right(); break; case 'j': cursor_down(); break; case 'k': cursor_up(); break; case 'w': //word forward. { int position = cur_left + cur_column - 1; int counter = 0; char *cur = get_line(cur_file, cur_top + cur_line - 1)->text; cur += cur_left + cur_column - 2; //to be checked. if (is_word_start(cur)) { position++; counter++; cur++; } for (; position < get_length(get_line(cur_file, cur_line + cur_top - 1)); position++, counter++) { if (is_word_start(cur++)) { break; } } for (; counter > 0; counter--) { cursor_right(); } } break; case 'b': //word backward. { int position = cur_left + cur_column - 1; int counter = 0; char *cur = get_line(cur_file, cur_top + cur_line - 1)->text; cur += cur_left + cur_column - 2; //to be checked. if (is_word_start(cur)) { position--; counter++; cur--; } for (; position > 0; position--, counter++) { if (is_word_start(cur--)) { break; } } for (; counter > 0; counter--) { cursor_left(); } } break; case 'e': //word-end forward. { int position = cur_left + cur_column - 1; int counter = 0; char *cur = get_line(cur_file, cur_top + cur_line - 1)->text; cur += cur_left + cur_column - 2; //to be checked. if (is_word_end(cur)) { position++; counter++; cur++; } for (; position < get_length(get_line(cur_file, cur_line + cur_top - 1)); position++, counter++) { if (is_word_end(cur++)) { break; } } for (; counter > 0; counter--) { cursor_right(); } } break; case 'i': //insert. mode_flag = INSERT_MODE; break; case 'a': //append. cursor_right(); mode_flag = INSERT_MODE; break; case 'd': //delete a word. { v_line *this_line = get_line(cur_file, cur_top + cur_line - 1); unsigned int word_len = 0; unsigned int start_index = cur_left + cur_column - 2; unsigned int end_index = judge_word(this_line, start_index + 1); word_len = end_index - start_index + 1; for (int i = 0; i < end_index - start_index + 1; i++) { del_char(this_line, cur_left + cur_column - 2); } if (word_len != 0) { changed_flag = CHANGED; } } break; case 'x': //delete a single char. del_char(get_line(cur_file, cur_top + cur_line - 1), cur_left + cur_column - 2); changed_flag = CHANGED; break; case 'o': //open new line. insert_empty_line(cur_file, cur_top + cur_line - 1); cursor_down(); mode_flag = INSERT_MODE; break; case '$': goto_line_end(); break; case '^': //goto first char of line. goto_line_actual_start(); break; case '0': //goto fixed first column. goto_line_start(); break; case '3': case ':': //bottom line command mode. //Now I wanna use this as open file command. if (changed_flag == CHANGED) { changed_flag = UNSAVED; break; } mode_flag = BOTTOMLINE_MODE; bottomline_sub_mode = BOTTOM_LINE_FILENAME_OPEN; break; case '/': //bottom line and search. break; case '2': case 's': if (strlen(cur_file_name) == 0) { mode_flag = BOTTOMLINE_MODE; bottomline_sub_mode = BOTTOM_LINE_FILENAME_SAVE; } else { v_save_file(cur_file_name, cur_file); changed_flag = UNCHANGED; } break; #ifdef __VIC_WIN case '\x00': case '\xe0': #endif default: break; } return 0; }
/* * Result: * 1: Found Result * -4: No result * -5: Result in another table * -6: Result in another chain * -7: Result in a chain not a rule */ int upnp_check_pinhole_working(const char * uid, char * eaddr, char * iaddr, unsigned short * eport, unsigned short * iport, char * protocol, int * rulenum_used) { /* TODO : to be implemented */ #if 0 FILE * fd; time_t expire = time(NULL); char buf[1024], filename[] = "/var/log/kern.log", expire_time[32]=""; int res = -4, str_len; str_len = strftime(expire_time, sizeof(expire_time), "%b %d %H:%M:%S", localtime(&expire)); fd = fopen(filename, "r"); if (fd==NULL) { return -1; } buf[sizeof(buf)-1] = 0; while(fgets(buf, sizeof(buf)-1, fd) != NULL && res != 1) { //printf("line: %s\n", buf); char * r, * t, * c, * p; // looking for something like filter:FORWARD:rule: or filter:MINIUPNPD:rule: r = strstr(buf, ":rule:"); p = strstr(buf, ":policy:"); t = strstr(buf, "TRACE:"); // table pointeur t += 7; c = t + 7; // chain pointeur if(r) { printf("\t** Found %.*s\n", 24 ,t); char * src, * dst, * sport, * dport, * proto, * line; char time[15]="", src_addr[40], dst_addr[40], proto_tmp[8]; int proto_int; strncpy(time, buf, sizeof(time)); /*if(compare_time(time, expire_time)<0) { printf("\t\tNot corresponding time\n"); continue; }*/ line = r + 6; printf("\trule line = %d\n", atoi(line)); src = strstr(buf, "SRC="); src += 4; snprintf(src_addr, sizeof(src_addr), "%.*s", 39, src); #if 0 del_char(src_addr); add_char(src_addr); #endif dst = strstr(buf, "DST="); dst += 4; snprintf(dst_addr, sizeof(dst_addr), "%.*s", 39, dst); #if 0 del_char(dst_addr); add_char(dst_addr); #endif proto = strstr(buf, "PROTO="); proto += 6; proto_int = atoi(protocol); if(proto_int == IPPROTO_UDP) strcpy(proto_tmp, "UDP"); else if(proto_int == IPPROTO_TCP) strcpy(proto_tmp, "TCP"); #ifdef IPPROTO_UDPLITE else if(proto_int == IPPROTO_UDPLITE) strcpy(proto_tmp, "UDPLITE"); #endif else strcpy(proto_tmp, "UnsupportedProto"); // printf("\tCompare eaddr: %s // protocol: %s\n\t to addr: %s // protocol: %.*s\n", eaddr, proto_tmp, src_addr, strlen(proto_tmp), proto); // printf("\tCompare iaddr: %s // protocol: %s\n\t to addr: %s // protocol: %.*s\n", iaddr, proto_tmp, dst_addr, strlen(proto_tmp), proto); // TODO Check time // Check that the paquet found in trace correspond to the one we are looking for if( /*(strcmp(eaddr, src_addr) == 0) &&*/ (strcmp(iaddr, dst_addr) == 0) && (strncmp(proto_tmp, proto, strlen(proto_tmp))==0)) { sport = strstr(buf, "SPT="); sport += 4; dport = strstr(buf, "DPT="); dport += 4; printf("\tCompare eport: %hu\n\t to port: %d\n", *eport, atoi(sport)); printf("\tCompare iport: %hu\n\t to port: %d\n", *iport, atoi(dport)); if(/*eport != atoi(sport) &&*/ *iport != atoi(dport)) { printf("\t\tPort not corresponding\n"); continue; } printf("\ttable found: %.*s\n", 6, t); printf("\tchain found: %.*s\n", 9, c); // Check that the table correspond to the filter table if(strncmp(t, "filter", 6)==0) { // Check that the table correspond to the MINIUPNP table if(strncmp(c, "MINIUPNPD", 9)==0) { *rulenum_used = atoi(line); res = 1; } else { res = -6; continue; } } else { res = -5; continue; } } else { printf("Packet information not corresponding\n"); continue; } } if(!r && p) { printf("\t** Policy case\n"); char * src, * dst, * sport, * dport, * proto, * line; char time[15], src_addr[40], dst_addr[40], proto_tmp[8]; int proto_int; strncpy(time, buf, sizeof(time)); /*if(compare_time(time, expire_time)<0) { printf("\t\tNot corresponding time\n"); continue; }*/ line = p + 8; printf("\trule line = %d\n", atoi(line)); src = strstr(buf, "SRC="); src += 4; snprintf(src_addr, sizeof(src_addr), "%.*s", 39, src); #if 0 del_char(src_addr); add_char(src_addr); #endif dst = strstr(buf, "DST="); dst += 4; snprintf(dst_addr, sizeof(dst_addr), "%.*s", 39, dst); #if 0 del_char(dst_addr); add_char(dst_addr); #endif proto = strstr(buf, "PROTO="); proto += 6; proto_int = atoi(protocol); if(proto_int == IPPROTO_UDP) strcpy(proto_tmp, "UDP"); else if(proto_int == IPPROTO_TCP) strcpy(proto_tmp, "TCP"); #ifdef IPPROTO_UDPLITE else if(proto_int == IPPROTO_UDPLITE) strcpy(proto_tmp, "UDPLITE"); #endif else strcpy(proto_tmp, "UnsupportedProto"); // printf("\tCompare eaddr: %s // protocol: %s\n\t to addr: %s // protocol: %.*s\n", eaddr, proto_tmp, src_addr, strlen(proto_tmp), proto); // printf("\tCompare iaddr: %s // protocol: %s\n\t to addr: %s // protocol: %.*s\n", iaddr, proto_tmp, dst_addr, strlen(proto_tmp), proto); // Check that the paquet found in trace correspond to the one we are looking for if( (strcmp(eaddr, src_addr) == 0) && (strcmp(iaddr, dst_addr) == 0) && (strncmp(proto_tmp, proto, 5)==0)) { sport = strstr(buf, "SPT="); sport += 4; dport = strstr(buf, "DPT="); dport += 4; printf("\tCompare eport: %hu\n\t to port: %d\n", *eport, atoi(sport)); printf("\tCompare iport: %hu\n\t to port: %d\n", *iport, atoi(dport)); if(*eport != atoi(sport) && *iport != atoi(dport)) { printf("\t\tPort not corresponding\n"); continue; } else { printf("Find a corresponding policy trace in the chain: %.*s\n", 10, c); res = -7; continue; } } else continue; } } fclose(fd); return res; #else return -4; #endif }
static int glw_text_bitmap_callback(glw_t *w, void *opaque, glw_signal_t signal, void *extra) { glw_text_bitmap_t *gtb = (void *)w; event_t *e; event_int_t *eu; switch(signal) { default: break; case GLW_SIGNAL_DESTROY: gtb_unbind(gtb); break; case GLW_SIGNAL_LAYOUT: glw_text_bitmap_layout(w, extra); break; case GLW_SIGNAL_INACTIVE: gtb_inactive(gtb); break; case GLW_SIGNAL_EVENT: if(w->glw_class == &glw_label) return 0; e = extra; if(event_is_action(e, ACTION_BS)) { del_char(gtb); gtb_notify(gtb); return 1; } else if(event_is_type(e, EVENT_UNICODE)) { eu = extra; if(insert_char(gtb, eu->val)) gtb_notify(gtb); return 1; } else if(event_is_action(e, ACTION_LEFT)) { if(gtb->gtb_edit_ptr > 0) { gtb->gtb_edit_ptr--; gtb->gtb_update_cursor = 1; return 1; } return 0; } else if(event_is_action(e, ACTION_RIGHT)) { if(gtb->gtb_edit_ptr < gtb->gtb_uc_len) { gtb->gtb_edit_ptr++; gtb->gtb_update_cursor = 1; return 1; } return 0; } else if(event_is_action(e, ACTION_ACTIVATE)) { if(w->glw_root->gr_open_osk != NULL) { char buf[512]; char *q = buf; int i; for(i = 0; i < gtb->gtb_uc_len; i++) q += utf8_put(q, gtb->gtb_uc_buffer[i]); *q = 0; w->glw_root->gr_open_osk(w->glw_root, NULL, buf, w, gtb->gtb_flags & GTB_PASSWORD); return 1; } } return 0; } return 0; }
// Importación de CSV a SC int import_csv(char * fname, char d) { register FILE * f; //int pid = 0; //int rfd = STDOUT_FILENO; int r = 0, c = 0; char line_in[FBUFLEN]; char line_interp[FBUFLEN] = ""; char * token; int quote = 0; // if value has '"'. ex: 12,"1234,450.00",56 char delim[2] = ""; //strtok receives a char *, not a char add_char(delim, d, 0); //if ((f = openfile(fname, & pid, & rfd)) == NULL) { if ((f = fopen(fname , "r")) == NULL) { error("Can't read file \"%s\"", fname); return -1; } // recorro archivo csv while ( ! feof(f) && (fgets(line_in, sizeof(line_in), f) != NULL) ) { // this hack is for importing file that have DOS eol int l = strlen(line_in); while (l--) if (line_in[l] == 0x0d) { line_in[l] = '\0'; break; } // rompo la cadena por delimitador token = xstrtok(line_in, delim); c = 0; while( token != NULL ) { clean_carrier(token); if ( (token[0] == '\"' || quote) && (token[strlen(token)-1] != '\"' || strlen(token) == 1) ) { quote = 1; sprintf(token + strlen(token), "%s", xstrtok(NULL, ",")); continue; } if (quote) { // elimino comillas si vengo de quote del_char(token, 0); del_char(token, strlen(token)-1); } if (isnumeric(token)) { sprintf(line_interp, "let %s%d=%s", coltoa(c), r, token); //} else if (token[0] == '"') { // sprintf(line_interp, "label %s%d=\"%s\"", coltoa(c), r, token); } else { sprintf(line_interp, "label %s%d=\"%s\"", coltoa(c), r, token); //info("label %s%d=\"%s\"", coltoa(c), r, token); //get_key(); } send_to_interp(line_interp); c++; quote = 0; token = xstrtok(NULL, ","); } r++; } maxrow = r-1; maxcol = c-1; auto_justify(0, maxcol, DEFWIDTH); //closefile(f, pid, rfd); fclose(f); EvalAll(); return 0; }
int main (void) { char x, y, temp, q; ioinit(); //Setup IO pins and defaults //USART_Init( MYUBRR); set_baud(6);//115200 rprintf_devopen(put_char); /* init rrprintf */ //check for existing preset values============================================================== temp = EEPROM_read((unsigned int)BPS); if ((temp < 1) | (temp > 6))//BPS will only be 1-6 { cli();//Disable Interrupts EEPROM_write((unsigned int) BPS, 6); EEPROM_write((unsigned int) BACKLIGHT, 100); EEPROM_write((unsigned int) SPLASH, 1); EEPROM_write((unsigned int) REV, 0); sei();//Enable Interrupts BL_dutycycle = 100; baud_rate = 6; splash_screen = 1; reverse = 0; } else { baud_rate = temp; BL_dutycycle = EEPROM_read((unsigned int)BACKLIGHT); splash_screen = EEPROM_read((unsigned int)SPLASH); reverse = EEPROM_read((unsigned int)REV); } //Reset the display PORTC &= ~(1 << RESET); delay_ms(50); PORTC |= (1 << RESET); //delay_ms(500); clear_screen(); set_page(0); set_x(0); display_on(); //set display start line to 0 //set control lines PORTC &= ~((1 << EN) | (1 << R_W) | (1 << RS));//down set_data(0xC0); //set_data(0xFF); delay(); PORTC |= (1 << EN);//up delay(); PORTC &= ~(1 << EN);//down delay(); PORTC |= ((1 << EN) | (1 << R_W) | (1 << RS));//all high delay(); x_offset = 0; set_page(0); DDRB |= (1<<BL_EN);//set PB2 as output set_backlight(BL_dutycycle); //Logo========================================================== if (splash_screen == 1) { y = 40; for (q = 0; q < 30; q++) { temp = logo[q]; for (x = 56; x < 64; x++) { if (temp & 0x80) pixel(1,x,y); temp <<= 1; } q++; temp = logo[q]; for (x = 64; x < 72; x++) { if (temp & 0x80) pixel(1,x,y); temp <<= 1; } y--; } } pixel(0,0,0);//cheat RX_in = 0; delay_ms(1000); clear_screen(); if (RX_in > 0)//revert to 115200 { print_char(1,'1'); print_char(1,'1'); print_char(1,'5'); print_char(1,'2'); print_char(1,'0'); print_char(1,'0'); baud_rate = 6; set_baud(6);//115200 cli(); EEPROM_write((unsigned int) BPS, 6); sei();//Enable Interrupts } else (set_baud(baud_rate)); delay_ms(1000); clear_screen(); //main loop=================================================== while(1) { if(RX_in != RX_read) { x = RX_array[RX_read]; RX_read++; if(RX_read >= 416) RX_read = 0; //Backspace=================================================== if(x == 8) del_char(0); //Special commands else if (x == 124) { //make sure the next byte is there while(RX_in == RX_read); //0, clear screen====================================================== if(RX_array[RX_read] == 0)//^@ { clear_screen(); RX_read++; if(RX_read >= 416) RX_read = 0; } //demo mode else if(RX_array[RX_read] == 4)//^d { RX_in = 0, RX_read = 0; demo(); clear_screen(); RX_in = 0; } //reverse mode else if(RX_array[RX_read] == 18)//^r { reverse ^= 1; clear_screen(); RX_read++; if(RX_read >= 416) RX_read = 0; cli(); EEPROM_write((unsigned int) REV, reverse); sei(); } //toggle spasl screen else if(RX_array[RX_read] == 19)//^s { splash_screen ^= 1; //clear_screen(); RX_read++; if(RX_read >= 416) RX_read = 0; cli(); EEPROM_write((unsigned int) SPLASH, splash_screen); sei(); } else { //set backlight (0 to 100)========================================================= if(RX_array[RX_read] == 2)//^b { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte BL_dutycycle = RX_array[RX_read]; RX_read++; if(RX_read >= 416) RX_read = 0; set_backlight(BL_dutycycle); cli(); EEPROM_write((unsigned int) BACKLIGHT, BL_dutycycle); sei(); } //change baud rate========================================================= if(RX_array[RX_read] == 7)//^g { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte //if (RX_array[RX_read] == '1') USART_Init( 1000000/2400-1);//4800 //else if (RX_array[RX_read] == '2') USART_Init( 1000000/4800-1);//9600 //else if (RX_array[RX_read] == '3') USART_Init( 1000000/9600-1);//19200 //else if (RX_array[RX_read] == '4') USART_Init( 1000000/19200-1);//38400 //else if (RX_array[RX_read] == '5') USART_Init( 1000000/28800-1);//57600 //else if (RX_array[RX_read] == '6') USART_Init( 1000000/57600-1);//115200 if ((RX_array[RX_read] > '0') * (RX_array[RX_read] < '7')) baud_rate = (RX_array[RX_read]) - 48; set_baud(baud_rate); cli(); EEPROM_write((unsigned int) BPS, baud_rate); sei(); RX_read++; if(RX_read >= 416) RX_read = 0; } //set x or y========================================================= if((RX_array[RX_read] == 24) | (RX_array[RX_read] == 25))//^x or ^y { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte if (RX_array[RX_read-1] == 24) x_offset = RX_array[RX_read]; else if (RX_array[RX_read-1] == 25) y_offset = RX_array[RX_read]; RX_read++; if(RX_read >= 416) RX_read = 0; if (x_offset > 159) x_offset = 159; if (y_offset > 127) y_offset = 127; } //set pixel========================================================= if (RX_array[RX_read] == 16)//^p { //need 3 bytes for (y = 0; y < 3; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } pixel(RX_array[RX_read], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 416) RX_read = 0; } //<ctrl>c, circle====================================================== if(RX_array[RX_read] == 3)//^c { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } circle(RX_array[RX_read], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 416) RX_read = 0; } //<ctrl>e, erase block====================================================== if(RX_array[RX_read] == 5)//^e { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } erase_block(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 416) RX_read = 0; } //box====================================================== if(RX_array[RX_read] == 15)//^o { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } box(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 416) RX_read = 0; } //line======================================================== else if (RX_array[RX_read] == 12)//^l { //need 5 bytes for (y = 0; y < 5; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } line(RX_array[RX_read], RX_array[RX_read-4], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read+-1]); RX_read++; if(RX_read >= 416) RX_read = 0; } } } //print character to the screen=============================================== else { del_char(1); print_char(1, x); } } } //demo(); }
void do_editmode(struct block * sb) { if (sb->value == 'h' || sb->value == OKEY_LEFT) { // LEFT inputline_pos = back_char(); } else if (sb->value == 'l' || sb->value == OKEY_RIGHT) { // RIGHT inputline_pos = for_char(); } else if (sb->value == 'x') { // x del_back_char(); } else if (sb->value == 'X') { // X del_for_char(); } else if (sb->value == ' ' && ( strlen(inputline) < (COLS - 14) ) ) { // SPACE add_char(inputline, ' ', inputline_pos); } else if (sb->value == 'r') { // r curs_set(1); int c = get_key(); if (c != -1) inputline[inputline_pos] = c; curs_set(2); } else if (sb->value == 'R') { // R curs_set(1); int c = get_key(); while (c != OKEY_ENTER && c != -1) { if (isprint(c)) { inputline[inputline_pos] = c; ++inputline_pos; mvwprintw(input_win, 0, 1 + rescol, "%s", inputline); wmove(input_win, 0, inputline_pos + 1 + rescol); wrefresh(input_win); } c = get_key(); } curs_set(2); } else if (sb->value == 'f') { // f int c = get_key(); if (c != -1) inputline_pos = look_for(c); } else if (sb->value == 'd' || sb->value == 'c') { // d or c int c, d; if ( (c = get_key()) != -1 ) { switch (c) { case 'e': // de or ce del_range_chars(inputline, inputline_pos, for_word(1, 0, 0)); break; case 'E': // dE or cE del_range_chars(inputline, inputline_pos, for_word(1, 0, 1)); break; case 'w': // dw or cw del_range_chars(inputline, inputline_pos, for_word(0, 1, 0) - 1); if (inputline_pos == strlen(inputline) && inputline_pos) inputline_pos--; break; case 'W': // dW or cW del_range_chars(inputline, inputline_pos, for_word(0, 1, 1) - 1); if (inputline_pos == strlen(inputline) && inputline_pos) inputline_pos--; break; case 'b': // db or cb d = back_word(0); del_range_chars(inputline, d, inputline_pos-1); inputline_pos = d; break; case 'B': // dB or cB d = back_word(1); del_range_chars(inputline, d, inputline_pos-1); inputline_pos = d; break; case 'l': // dl or cl case OKEY_RIGHT: del_back_char(); break; case 'h': // dh or ch case OKEY_LEFT: del_for_char(); break; case 'a': if ( (d = get_key()) == 'W' ) { // daW or caW c = ( inputline_pos && inputline[inputline_pos-1] == ' ' ) ? inputline_pos : back_word(1); del_range_chars(inputline, c, for_word(0, 1, 1) - 1); inputline_pos = (strlen(inputline) > inputline_pos) ? c : strlen(inputline)-2; } else if ( d == 'w' ) { // daw or caw d = ( inputline_pos && ! istext( inputline[inputline_pos-1]) ) ? inputline_pos : back_word(0); del_range_chars(inputline, d, for_word(0, 1, 0) - 1); inputline_pos = (strlen(inputline) > inputline_pos) ? d : strlen(inputline)-2; } break; } if (sb->value == 'c') chg_mode(insert_edit_submode); } } else if (find_val(sb, OKEY_ENTER)) { // ENTER insert_or_edit_cell(); return; } else if (sb->value == '$') { // $ inputline_pos = strlen(inputline) - 1; } else if (sb->value == 'w') { // w inputline_pos = for_word(0, 0, 0); } else if (sb->value == 'W') { // W inputline_pos = for_word(0, 0, 1); } else if (sb->value == 'e') { // e inputline_pos = for_word(1, 0, 0); } else if (sb->value == 'E') { // E inputline_pos = for_word(1, 0, 1); } else if (sb->value == 'b') { // b inputline_pos = back_word(0); } else if (sb->value == 'B') { // B inputline_pos = back_word(1); } else if (sb->value == '0') { // 0 inputline_pos = 0; } else if (sb->value == 'a') { // a inputline_pos++; chg_mode(insert_edit_submode); } else if (sb->value == 'i' || sb->value == '=') { // i o = chg_mode(insert_edit_submode); } else if (sb->value == 's') { // s if (inputline_pos <= strlen(inputline)) del_char(inputline, inputline_pos); chg_mode(insert_edit_submode); } else if (sb->value == 'A') { // A inputline_pos = strlen(inputline); chg_mode(insert_edit_submode); } else if (sb->value == 'I') { // I inputline_pos = 0; chg_mode(insert_edit_submode); } else if (sb->value == 'D') { // D inputline_pos = 0; inputline[0] = '\0'; chg_mode(insert_edit_submode); } show_header(input_win); return; }
static int glw_text_bitmap_event(glw_t *w, event_t *e) { glw_text_bitmap_t *gtb = (glw_text_bitmap_t *)w; if(event_is_action(e, ACTION_BS)) { del_char(gtb); gtb_notify(gtb); return 1; } else if(event_is_type(e, EVENT_UNICODE)) { event_int_t *eu = (event_int_t *)e; if(insert_char(gtb, eu->val)) gtb_notify(gtb); return 1; } else if(event_is_type(e, EVENT_INSERT_STRING)) { event_payload_t *ep = (event_payload_t *)e; const char *str = ep->payload; int uc; while((uc = utf8_get(&str)) != 0) { insert_char(gtb, uc); } gtb_notify(gtb); return 1; } else if(event_is_action(e, ACTION_LEFT)) { if(gtb->gtb_edit_ptr > 0) { gtb->gtb_edit_ptr--; gtb->gtb_update_cursor = 1; } return 1; } else if(event_is_action(e, ACTION_RIGHT)) { if(gtb->gtb_edit_ptr < gtb->gtb_uc_len) { gtb->gtb_edit_ptr++; gtb->gtb_update_cursor = 1; } return 1; } else if(event_is_action(e, ACTION_ACTIVATE) || event_is_action(e, ACTION_ITEMMENU)) { gtb_caption_refresh(gtb); if(gtb->gtb_flags & (GTB_FILE_REQUEST | GTB_DIR_REQUEST)) { if(gtb->gtb_p == NULL) { TRACE(TRACE_ERROR, "GLW", "File requests on unbound widgets is not supported"); } else { int flags = (gtb->gtb_flags & GTB_FILE_REQUEST ? FILEPICKER_FILES : 0) | (gtb->gtb_flags & GTB_DIR_REQUEST ? FILEPICKER_DIRECTORIES : 0); filepicker_pick_to_prop(gtb->gtb_description, gtb->gtb_p, gtb->gtb_caption, flags); } } else { if(event_is_action(e, ACTION_ACTIVATE) && e->e_flags & EVENT_MOUSE) return 1; w->glw_root->gr_open_osk(w->glw_root, gtb->gtb_description, gtb->gtb_caption, w, gtb->gtb_flags & GTB_PASSWORD); } return 1; } return 0; }
el_status_t el_del_char(void) { return del_char(); }
void uart_console_isr(struct device *unused) { ARG_UNUSED(unused); while (uart_irq_update(uart_console_dev) && uart_irq_is_pending(uart_console_dev)) { static struct uart_console_input *cmd; uint8_t byte; int rx; if (!uart_irq_rx_ready(uart_console_dev)) { continue; } /* Character(s) have been received */ rx = read_uart(uart_console_dev, &byte, 1); if (rx < 0) { return; } if (uart_irq_input_hook(uart_console_dev, byte) != 0) { /* * The input hook indicates that no further processing * should be done by this handler. */ return; } if (!cmd) { cmd = nano_isr_fifo_get(avail_queue, TICKS_NONE); if (!cmd) return; } /* Handle ANSI escape mode */ if (atomic_test_bit(&esc_state, ESC_ANSI)) { handle_ansi(byte); continue; } /* Handle escape mode */ if (atomic_test_and_clear_bit(&esc_state, ESC_ESC)) { switch (byte) { case ANSI_ESC: atomic_set_bit(&esc_state, ESC_ANSI); atomic_set_bit(&esc_state, ESC_ANSI_FIRST); break; default: break; } continue; } /* Handle special control characters */ if (!isprint(byte)) { switch (byte) { case DEL: if (cur > 0) { del_char(&cmd->line[--cur], end); } break; case ESC: atomic_set_bit(&esc_state, ESC_ESC); break; case '\r': cmd->line[cur + end] = '\0'; uart_poll_out(uart_console_dev, '\r'); uart_poll_out(uart_console_dev, '\n'); cur = 0; end = 0; nano_isr_fifo_put(lines_queue, cmd); cmd = NULL; break; case '\t': if (completion_cb && !end) { cur += completion_cb(cmd->line, cur); } break; default: break; } continue; } /* Ignore characters if there's no more buffer space */ if (cur + end < sizeof(cmd->line) - 1) { insert_char(&cmd->line[cur++], byte, end); } } }
/// Map Farsi keyboard when in fkmap mode. int fkmap(int c) { int tempc; static int revins; if (IS_SPECIAL(c)) { return c; } if (VIM_ISDIGIT(c) || (((c == '.') || (c == '+') || (c == '-') || (c == '^') || (c == '%') || (c == '#') || (c == '=')) && revins)) { if (!revins) { if (curwin->w_cursor.col) { if (!p_ri) { dec_cursor(); } chg_c_toX_orX(); chg_l_toXor_X(); if (!p_ri) { inc_cursor(); } } } arrow_used = TRUE; (void)stop_arrow(); if (!curwin->w_p_rl && revins) { inc_cursor(); } revins++; p_ri = 1; } else { if (revins) { arrow_used = TRUE; (void)stop_arrow(); revins = 0; if (curwin->w_p_rl) { while ((F_isdigit(gchar_cursor()) || (gchar_cursor() == F_PERIOD || gchar_cursor() == F_PLUS || gchar_cursor() == F_MINUS || gchar_cursor() == F_MUL || gchar_cursor() == F_DIVIDE || gchar_cursor() == F_PERCENT || gchar_cursor() == F_EQUALS)) && gchar_cursor() != '\0') { curwin->w_cursor.col++; } } else { if (curwin->w_cursor.col) { while ((F_isdigit(gchar_cursor()) || (gchar_cursor() == F_PERIOD || gchar_cursor() == F_PLUS || gchar_cursor() == F_MINUS || gchar_cursor() == F_MUL || gchar_cursor() == F_DIVIDE || gchar_cursor() == F_PERCENT || gchar_cursor() == F_EQUALS)) && --curwin->w_cursor.col) { } } if (!F_isdigit(gchar_cursor())) { ++curwin->w_cursor.col; } } } } if (!revins) { if (curwin->w_p_rl) { p_ri = 0; } if (!curwin->w_p_rl) { p_ri = 1; } } if ((c < 0x100) && (isalpha(c) || (c == '&') || (c == '^') || (c == ';') || (c == '\'') || (c == ',') || (c == '[') || (c == ']') || (c == '{') || (c == '}'))) { chg_r_to_Xor_X_(); } tempc = 0; switch (c) { case '`': case ' ': case '.': case '!': case '"': case '$': case '%': case '^': case '&': case '/': case '(': case ')': case '=': case '\\': case '?': case '+': case '-': case '_': case '*': case ':': case '#': case '~': case '@': case '<': case '>': case '{': case '}': case '|': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'B': case 'E': case 'F': case 'H': case 'I': case 'K': case 'L': case 'M': case 'O': case 'P': case 'Q': case 'R': case 'T': case 'U': case 'W': case 'Y': case NL: case TAB: if (p_ri && (c == NL) && curwin->w_cursor.col) { // If the char before the cursor is _X_ or X_ do not change // the one under the cursor with X type. dec_cursor(); if (F_isalpha(gchar_cursor())) { inc_cursor(); return NL; } inc_cursor(); } if (!p_ri) { if (!curwin->w_cursor.col) { switch (c) { case '0': return FARSI_0; case '1': return FARSI_1; case '2': return FARSI_2; case '3': return FARSI_3; case '4': return FARSI_4; case '5': return FARSI_5; case '6': return FARSI_6; case '7': return FARSI_7; case '8': return FARSI_8; case '9': return FARSI_9; case 'B': return F_PSP; case 'E': return JAZR_N; case 'F': return ALEF_D_H; case 'H': return ALEF_A; case 'I': return TASH; case 'K': return F_LQUOT; case 'L': return F_RQUOT; case 'M': return HAMZE; case 'O': return '['; case 'P': return ']'; case 'Q': return OO; case 'R': return MAD_N; case 'T': return OW; case 'U': return MAD; case 'W': return OW_OW; case 'Y': return JAZR; case '`': return F_PCN; case '!': return F_EXCL; case '@': return F_COMMA; case '#': return F_DIVIDE; case '$': return F_CURRENCY; case '%': return F_PERCENT; case '^': return F_MUL; case '&': return F_BCOMMA; case '*': return F_STAR; case '(': return F_LPARENT; case ')': return F_RPARENT; case '-': return F_MINUS; case '_': return F_UNDERLINE; case '=': return F_EQUALS; case '+': return F_PLUS; case '\\': return F_BSLASH; case '|': return F_PIPE; case ':': return F_DCOLON; case '"': return F_SEMICOLON; case '.': return F_PERIOD; case '/': return F_SLASH; case '<': return F_LESS; case '>': return F_GREATER; case '?': return F_QUESTION; case ' ': return F_BLANK; } break; } } if (!p_ri) { dec_cursor(); } switch ((tempc = gchar_cursor())) { case _BE: case _PE: case _TE: case _SE: case _JIM: case _CHE: case _HE_J: case _XE: case _SIN: case _SHIN: case _SAD: case _ZAD: case _FE: case _GHAF: case _KAF: case _KAF_H: case _GAF: case _LAM: case _MIM: case _NOON: case _HE: case _HE_: case _TA: case _ZA: put_curr_and_l_to_X(toF_TyA(tempc)); break; case _AYN: case _AYN_: if (!p_ri) { if (!curwin->w_cursor.col) { put_curr_and_l_to_X(AYN); break; } } if (p_ri) { inc_cursor(); } else { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = AYN_; } else { tempc = AYN; } if (p_ri) { dec_cursor(); } else { inc_cursor(); } put_curr_and_l_to_X(tempc); break; case _GHAYN: case _GHAYN_: if (!p_ri) { if (!curwin->w_cursor.col) { put_curr_and_l_to_X(GHAYN); break; } } if (p_ri) { inc_cursor(); } else { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = GHAYN_; } else { tempc = GHAYN; } if (p_ri) { dec_cursor(); } else { inc_cursor(); } put_curr_and_l_to_X(tempc); break; case _YE: case _IE: case _YEE: if (!p_ri) { if (!curwin->w_cursor.col) { put_curr_and_l_to_X((tempc == _YE ? YE : (tempc == _IE ? IE : YEE))); break; } } if (p_ri) { inc_cursor(); } else { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = (tempc == _YE ? YE_ : (tempc == _IE ? IE_ : YEE_)); } else { tempc = (tempc == _YE ? YE : (tempc == _IE ? IE : YEE)); } if (p_ri) { dec_cursor(); } else { inc_cursor(); } put_curr_and_l_to_X(tempc); break; } if (!p_ri) { inc_cursor(); } tempc = 0; switch (c) { case '0': return FARSI_0; case '1': return FARSI_1; case '2': return FARSI_2; case '3': return FARSI_3; case '4': return FARSI_4; case '5': return FARSI_5; case '6': return FARSI_6; case '7': return FARSI_7; case '8': return FARSI_8; case '9': return FARSI_9; case 'B': return F_PSP; case 'E': return JAZR_N; case 'F': return ALEF_D_H; case 'H': return ALEF_A; case 'I': return TASH; case 'K': return F_LQUOT; case 'L': return F_RQUOT; case 'M': return HAMZE; case 'O': return '['; case 'P': return ']'; case 'Q': return OO; case 'R': return MAD_N; case 'T': return OW; case 'U': return MAD; case 'W': return OW_OW; case 'Y': return JAZR; case '`': return F_PCN; case '!': return F_EXCL; case '@': return F_COMMA; case '#': return F_DIVIDE; case '$': return F_CURRENCY; case '%': return F_PERCENT; case '^': return F_MUL; case '&': return F_BCOMMA; case '*': return F_STAR; case '(': return F_LPARENT; case ')': return F_RPARENT; case '-': return F_MINUS; case '_': return F_UNDERLINE; case '=': return F_EQUALS; case '+': return F_PLUS; case '\\': return F_BSLASH; case '|': return F_PIPE; case ':': return F_DCOLON; case '"': return F_SEMICOLON; case '.': return F_PERIOD; case '/': return F_SLASH; case '<': return F_LESS; case '>': return F_GREATER; case '?': return F_QUESTION; case ' ': return F_BLANK; } break; case 'a': tempc = _SHIN; break; case 'A': tempc = WAW_H; break; case 'b': tempc = ZAL; break; case 'c': tempc = ZE; break; case 'C': tempc = JE; break; case 'd': tempc = _YE; break; case 'D': tempc = _YEE; break; case 'e': tempc = _SE; break; case 'f': tempc = _BE; break; case 'g': tempc = _LAM; break; case 'G': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (gchar_cursor() == _LAM) { chg_c_toX_orX(); } else if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri) { if (!curwin->w_cursor.col) { return ALEF_U_H; } } if (!p_ri) { dec_cursor(); } if (gchar_cursor() == _LAM) { chg_c_toX_orX(); chg_l_toXor_X(); tempc = ALEF_U_H; } else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = ALEF_U_H_; chg_l_toXor_X(); } else { tempc = ALEF_U_H; } if (!p_ri) { inc_cursor(); } return tempc; case 'h': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri) { if (!curwin->w_cursor.col) { return ALEF; } } if (!p_ri) { dec_cursor(); } if (gchar_cursor() == _LAM) { chg_l_toXor_X(); del_char(FALSE); AppendCharToRedobuff(K_BS); if (!p_ri) { dec_cursor(); } tempc = LA; } else { if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = ALEF_; chg_l_toXor_X(); } else { tempc = ALEF; } } if (!p_ri) { inc_cursor(); } return tempc; case 'i': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri && !curwin->w_cursor.col) { return _HE; } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = _HE_; } else { tempc = _HE; } if (!p_ri) { inc_cursor(); } break; case 'j': tempc = _TE; break; case 'J': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri) { if (!curwin->w_cursor.col) { return TEE; } } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = TEE_; chg_l_toXor_X(); } else { tempc = TEE; } if (!p_ri) { inc_cursor(); } return tempc; case 'k': tempc = _NOON; break; case 'l': tempc = _MIM; break; case 'm': tempc = _PE; break; case 'n': case 'N': tempc = DAL; break; case 'o': tempc = _XE; break; case 'p': tempc = _HE_J; break; case 'q': tempc = _ZAD; break; case 'r': tempc = _GHAF; break; case 's': tempc = _SIN; break; case 'S': tempc = _IE; break; case 't': tempc = _FE; break; case 'u': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri && !curwin->w_cursor.col) { return _AYN; } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = _AYN_; } else { tempc = _AYN; } if (!p_ri) { inc_cursor(); } break; case 'v': case 'V': tempc = RE; break; case 'w': tempc = _SAD; break; case 'x': case 'X': tempc = _TA; break; case 'y': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri && !curwin->w_cursor.col) { return _GHAYN; } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = _GHAYN_; } else { tempc = _GHAYN; } if (!p_ri) { inc_cursor(); } break; case 'z': tempc = _ZA; break; case 'Z': tempc = _KAF_H; break; case ';': tempc = _KAF; break; case '\'': tempc = _GAF; break; case ',': tempc = WAW; break; case '[': tempc = _JIM; break; case ']': tempc = _CHE; break; } if ((F_isalpha(tempc) || F_isdigit(tempc))) { if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (curwin->w_cursor.col) { if (!p_ri) { dec_cursor(); } if (F_is_TyE(tempc)) { chg_l_toXor_X(); } else { chg_l_to_X_orX_(); } if (!p_ri) { inc_cursor(); } } } if (tempc) { return tempc; } return c; }