cv_action(): * Handle vi actions. */
| 58 | * Handle vi actions. |
| 59 | */ |
| 60 | private el_action_t |
| 61 | cv_action(EditLine *el, Int c) |
| 62 | { |
| 63 | |
| 64 | if (el->el_chared.c_vcmd.action != NOP) { |
| 65 | /* 'cc', 'dd' and (possibly) friends */ |
| 66 | if (c != (Int)el->el_chared.c_vcmd.action) |
| 67 | return CC_ERROR; |
| 68 | |
| 69 | if (!(c & YANK)) |
| 70 | cv_undo(el); |
| 71 | cv_yank(el, el->el_line.buffer, |
| 72 | (int)(el->el_line.lastchar - el->el_line.buffer)); |
| 73 | el->el_chared.c_vcmd.action = NOP; |
| 74 | el->el_chared.c_vcmd.pos = 0; |
| 75 | if (!(c & YANK)) { |
| 76 | el->el_line.lastchar = el->el_line.buffer; |
| 77 | el->el_line.cursor = el->el_line.buffer; |
| 78 | } |
| 79 | if (c & INSERT) |
| 80 | el->el_map.current = el->el_map.key; |
| 81 | |
| 82 | return CC_REFRESH; |
| 83 | } |
| 84 | el->el_chared.c_vcmd.pos = el->el_line.cursor; |
| 85 | el->el_chared.c_vcmd.action = c; |
| 86 | return CC_ARGHACK; |
| 87 | } |
| 88 | |
| 89 | /* cv_paste(): |
| 90 | * Paste previous deletion before or after the cursor |
no test coverage detected