mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[clipboard] Allow to change rectangle in both directions
This commit is contained in:
parent
ed93225510
commit
effb18d31f
@ -175,7 +175,7 @@ draw_clipboard(struct terminal *term, struct document_view *doc_view)
|
|||||||
assert(term && doc_view);
|
assert(term && doc_view);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
if (!document->clipboard_box.height || !document->clipboard_box.width) {
|
if (document->clipboard_status == CLIPBOARD_NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +188,22 @@ draw_clipboard(struct terminal *term, struct document_view *doc_view)
|
|||||||
startx = int_max(0, document->clipboard_box.x + xoffset);
|
startx = int_max(0, document->clipboard_box.x + xoffset);
|
||||||
endx = int_min(doc_view->box.width, document->clipboard_box.x + document->clipboard_box.width + xoffset);
|
endx = int_min(doc_view->box.width, document->clipboard_box.x + document->clipboard_box.width + xoffset);
|
||||||
|
|
||||||
for (y = starty; y < endy; ++y) {
|
if (endy < starty) {
|
||||||
for (x = startx; x < endx; ++x) {
|
int tmp = endy;
|
||||||
|
|
||||||
|
endy = starty;
|
||||||
|
starty = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endx < startx) {
|
||||||
|
int tmp = endx;
|
||||||
|
|
||||||
|
endx = startx;
|
||||||
|
startx = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y = starty; y <= endy; ++y) {
|
||||||
|
for (x = startx; x <= endx; ++x) {
|
||||||
draw_char_color(term, x, y, color);
|
draw_char_color(term, x, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -969,16 +969,8 @@ move_clipboard_pos(struct session *ses, struct document_view *view, enum frame_e
|
|||||||
x = ses->tab->x + xoffset;
|
x = ses->tab->x + xoffset;
|
||||||
y = ses->tab->y + yoffset;
|
y = ses->tab->y + yoffset;
|
||||||
|
|
||||||
if (document->clipboard_box.x == x && document->clipboard_box.y == y) {
|
document->clipboard_box.height = y - document->clipboard_box.y;
|
||||||
return status;
|
document->clipboard_box.width = x - document->clipboard_box.x;
|
||||||
}
|
|
||||||
|
|
||||||
if (document->clipboard_box.x > x || document->clipboard_box.y > y) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
document->clipboard_box.height = y - document->clipboard_box.y + 1;
|
|
||||||
document->clipboard_box.width = x - document->clipboard_box.x + 1;
|
|
||||||
|
|
||||||
return FRAME_EVENT_REFRESH;
|
return FRAME_EVENT_REFRESH;
|
||||||
}
|
}
|
||||||
@ -988,10 +980,10 @@ copy_to_clipboard2(struct document_view *doc_view)
|
|||||||
{
|
{
|
||||||
struct document *document = doc_view->document;
|
struct document *document = doc_view->document;
|
||||||
struct string data;
|
struct string data;
|
||||||
int starty, endy, startx, y;
|
int starty, endy, startx, y, endx;
|
||||||
int utf8;
|
int utf8;
|
||||||
|
|
||||||
if (!document->clipboard_box.height || !document->clipboard_box.width) {
|
if (document->clipboard_status == CLIPBOARD_NONE) {
|
||||||
return FRAME_EVENT_OK;
|
return FRAME_EVENT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,16 +991,29 @@ copy_to_clipboard2(struct document_view *doc_view)
|
|||||||
return FRAME_EVENT_OK;
|
return FRAME_EVENT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
starty = document->clipboard_box.y;
|
if (document->clipboard_box.height >= 0) {
|
||||||
endy = int_min(document->clipboard_box.y + document->clipboard_box.height, document->height);
|
starty = document->clipboard_box.y;
|
||||||
startx = document->clipboard_box.x;
|
endy = int_min(document->clipboard_box.y + document->clipboard_box.height, document->height);
|
||||||
|
} else {
|
||||||
|
endy = document->clipboard_box.y;
|
||||||
|
starty = int_max(document->clipboard_box.y + document->clipboard_box.height, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document->clipboard_box.width >= 0) {
|
||||||
|
startx = document->clipboard_box.x;
|
||||||
|
endx = document->clipboard_box.x + document->clipboard_box.width;
|
||||||
|
} else {
|
||||||
|
endx = document->clipboard_box.x;
|
||||||
|
startx = int_max(document->clipboard_box.x + document->clipboard_box.width, 0);
|
||||||
|
}
|
||||||
|
|
||||||
utf8 = document->options.utf8;
|
utf8 = document->options.utf8;
|
||||||
|
|
||||||
for (y = starty; y < endy; y++) {
|
for (y = starty; y <= endy; y++) {
|
||||||
int endx = int_min(document->clipboard_box.x + document->clipboard_box.width, document->data[y].length);
|
int ex = int_min(endx, document->data[y].length - 1);
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for (x = startx; x < endx; x++) {
|
for (x = startx; x <= ex; x++) {
|
||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
unicode_val_T c;
|
unicode_val_T c;
|
||||||
#else
|
#else
|
||||||
@ -1069,21 +1074,15 @@ mark_clipboard(struct session *ses, struct document_view *doc_view)
|
|||||||
case CLIPBOARD_NONE:
|
case CLIPBOARD_NONE:
|
||||||
document->clipboard_box.x = x;
|
document->clipboard_box.x = x;
|
||||||
document->clipboard_box.y = y;
|
document->clipboard_box.y = y;
|
||||||
document->clipboard_box.height = 1;
|
document->clipboard_box.height = 0;
|
||||||
document->clipboard_box.width = 1;
|
document->clipboard_box.width = 0;
|
||||||
document->clipboard_status = CLIPBOARD_FIRST_POINT;
|
document->clipboard_status = CLIPBOARD_FIRST_POINT;
|
||||||
|
|
||||||
return FRAME_EVENT_OK;
|
return FRAME_EVENT_REFRESH;
|
||||||
|
|
||||||
case CLIPBOARD_FIRST_POINT:
|
case CLIPBOARD_FIRST_POINT:
|
||||||
if (document->clipboard_box.x == x && document->clipboard_box.y == y) {
|
document->clipboard_box.height = y - document->clipboard_box.y;
|
||||||
return FRAME_EVENT_OK;
|
document->clipboard_box.width = x - document->clipboard_box.x;
|
||||||
}
|
|
||||||
if (document->clipboard_box.x > x || document->clipboard_box.y > y) {
|
|
||||||
return FRAME_EVENT_OK;
|
|
||||||
}
|
|
||||||
document->clipboard_box.height = y - document->clipboard_box.y + 1;
|
|
||||||
document->clipboard_box.width = x - document->clipboard_box.x + 1;
|
|
||||||
document->clipboard_status = CLIPBOARD_SECOND_POINT;
|
document->clipboard_status = CLIPBOARD_SECOND_POINT;
|
||||||
|
|
||||||
return FRAME_EVENT_REFRESH;
|
return FRAME_EVENT_REFRESH;
|
||||||
@ -1129,9 +1128,7 @@ copy_current_link_to_clipboard(struct session *ses,
|
|||||||
enum frame_event_status
|
enum frame_event_status
|
||||||
copy_to_clipboard(struct session *ses, struct document_view *doc_view)
|
copy_to_clipboard(struct session *ses, struct document_view *doc_view)
|
||||||
{
|
{
|
||||||
if (doc_view && doc_view->document
|
if (doc_view && doc_view->document && doc_view->document->clipboard_status != CLIPBOARD_NONE) {
|
||||||
&& doc_view->document->clipboard_box.height
|
|
||||||
&& doc_view->document->clipboard_box.width) {
|
|
||||||
return copy_to_clipboard2(doc_view);
|
return copy_to_clipboard2(doc_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user