| 288 | } |
| 289 | |
| 290 | static void insert_line(TextEditorState *state, char *line, int pos) { |
| 291 | int offset = state->offset_list[pos]; |
| 292 | |
| 293 | // calculated size of inserted line |
| 294 | int length = strlen(line); |
| 295 | |
| 296 | // Make space for inserted line |
| 297 | memmove(&state->buffer[offset + length], &state->buffer[offset], state->size - offset); |
| 298 | state->size += length; |
| 299 | |
| 300 | // Insert the lines |
| 301 | memcpy(&state->buffer[offset], line, length); |
| 302 | |
| 303 | int i; |
| 304 | for (i = 0; i < length; i++) { |
| 305 | if (line[i] == '\n') { |
| 306 | state->n_lines++; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | state->n_selections = 0; |
| 311 | state->changed = 1; |
| 312 | state->copy_reset = 1; |
| 313 | |
| 314 | // Update entries |
| 315 | updateTextEntries(state); |
| 316 | } |
| 317 | |
| 318 | static void cut_line(TextEditorState *state, int line_number) { |
| 319 | copy_line(state, line_number); |
no test coverage detected