static void tinput_sel_copy_to_cb(tinput_t *ti) { size_t sa; size_t sb; tinput_sel_get_bounds(ti, &sa, &sb); char *str; if (sb < ti->nc) { wchar_t tmp_c = ti->buffer[sb]; ti->buffer[sb] = '\0'; str = wstr_to_astr(ti->buffer + sa); ti->buffer[sb] = tmp_c; } else str = wstr_to_astr(ti->buffer + sa); if (str == NULL) goto error; if (clipboard_put_str(str) != EOK) goto error; free(str); return; error: /* TODO: Give the user some kind of warning. */ return; }
static void selection_copy(void) { spt_t pa, pb; char *str; selection_get_points(&pa, &pb); str = range_get_str(&pa, &pb); if (str == NULL || clipboard_put_str(str) != EOK) { status_display("Copying to clipboard failed!"); } free(str); }