forked from enlightenment/terminology
keep selection when scrolling
This commit is contained in:
parent
d682db21fb
commit
bc15fc6ff6
|
@ -3941,12 +3941,13 @@ _smart_pty_change(void *data)
|
||||||
_smart_update_queue(data, sd);
|
_smart_update_queue(data, sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
_smart_pty_scroll(void *data)
|
termio_scroll(Evas_Object *obj, int direction)
|
||||||
{
|
{
|
||||||
Evas_Object *obj = data;
|
|
||||||
Termio *sd;
|
Termio *sd;
|
||||||
|
Termpty *ty;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
sd = evas_object_smart_data_get(obj);
|
sd = evas_object_smart_data_get(obj);
|
||||||
if (!sd) return;
|
if (!sd) return;
|
||||||
|
|
||||||
|
@ -3959,13 +3960,14 @@ _smart_pty_scroll(void *data)
|
||||||
sd->scroll = sd->pty->backscroll_num;
|
sd->scroll = sd->pty->backscroll_num;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
if (sd->pty->selection.is_active)
|
ty = sd->pty;
|
||||||
|
if (ty->selection.is_active)
|
||||||
{
|
{
|
||||||
sd->pty->selection.start.y--;
|
ty->selection.start.y += direction;
|
||||||
sd->pty->selection.end.y--;
|
ty->selection.end.y += direction;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
if (changed) _smart_update_queue(data, sd);
|
if (changed) _smart_update_queue(obj, sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -4402,8 +4404,6 @@ termio_add(Evas_Object *parent, Config *config, const char *cmd, Eina_Bool login
|
||||||
sd->pty->obj = obj;
|
sd->pty->obj = obj;
|
||||||
sd->pty->cb.change.func = _smart_pty_change;
|
sd->pty->cb.change.func = _smart_pty_change;
|
||||||
sd->pty->cb.change.data = obj;
|
sd->pty->cb.change.data = obj;
|
||||||
sd->pty->cb.scroll.func = _smart_pty_scroll;
|
|
||||||
sd->pty->cb.scroll.data = obj;
|
|
||||||
sd->pty->cb.set_title.func = _smart_pty_title;
|
sd->pty->cb.set_title.func = _smart_pty_title;
|
||||||
sd->pty->cb.set_title.data = obj;
|
sd->pty->cb.set_title.data = obj;
|
||||||
sd->pty->cb.set_icon.func = _smart_pty_icon;
|
sd->pty->cb.set_icon.func = _smart_pty_icon;
|
||||||
|
|
|
@ -12,6 +12,7 @@ char *termio_selection_get(Evas_Object *obj,
|
||||||
int c1x, int c1y, int c2x, int c2y,
|
int c1x, int c1y, int c2x, int c2y,
|
||||||
size_t *len);
|
size_t *len);
|
||||||
Eina_Bool termio_selection_exists(const Evas_Object *obj);
|
Eina_Bool termio_selection_exists(const Evas_Object *obj);
|
||||||
|
void termio_scroll(Evas_Object *obj, int direction);
|
||||||
|
|
||||||
void termio_config_update(Evas_Object *obj);
|
void termio_config_update(Evas_Object *obj);
|
||||||
Config *termio_config_get(const Evas_Object *obj);
|
Config *termio_config_get(const Evas_Object *obj);
|
||||||
|
|
|
@ -109,7 +109,7 @@ struct _Termpty
|
||||||
struct {
|
struct {
|
||||||
void (*func) (void *data);
|
void (*func) (void *data);
|
||||||
void *data;
|
void *data;
|
||||||
} change, scroll, set_title, set_icon, cancel_sel, exited, bell, command;
|
} change, set_title, set_icon, cancel_sel, exited, bell, command;
|
||||||
} cb;
|
} cb;
|
||||||
struct {
|
struct {
|
||||||
const char *title, *icon;
|
const char *title, *icon;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
#include "termio.h"
|
||||||
#include "termpty.h"
|
#include "termpty.h"
|
||||||
#include "termptydbl.h"
|
#include "termptydbl.h"
|
||||||
#include "termptyops.h"
|
#include "termptyops.h"
|
||||||
|
@ -70,24 +71,18 @@ _termpty_text_scroll(Termpty *ty, Eina_Bool clear)
|
||||||
end_y = ty->state.scroll_y2 - 1;
|
end_y = ty->state.scroll_y2 - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
if (!ty->altbuf)
|
||||||
if (!ty->altbuf)
|
termpty_text_save_top(ty, &(TERMPTY_SCREEN(ty, 0, 0)), ty->w);
|
||||||
{
|
|
||||||
termpty_text_save_top(ty, &(TERMPTY_SCREEN(ty, 0, 0)), ty->w);
|
termio_scroll(ty->obj, -1);
|
||||||
if (ty->cb.scroll.func) ty->cb.scroll.func(ty->cb.scroll.data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (ty->cb.cancel_sel.func)
|
|
||||||
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
|
|
||||||
}
|
|
||||||
DBG("... scroll!!!!! [%i->%i]", start_y, end_y);
|
DBG("... scroll!!!!! [%i->%i]", start_y, end_y);
|
||||||
|
|
||||||
if (start_y == 0 && end_y == ty->h - 1)
|
if (start_y == 0 && end_y == ty->h - 1)
|
||||||
{
|
{
|
||||||
// screen is a circular buffer now
|
// screen is a circular buffer now
|
||||||
cells2 = &(ty->screen[ty->circular_offset * ty->w]);
|
cells = &(ty->screen[ty->circular_offset * ty->w]);
|
||||||
if (clear)
|
if (clear)
|
||||||
_text_clear(ty, cells2, ty->w, 0, EINA_TRUE);
|
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
|
||||||
|
|
||||||
ty->circular_offset++;
|
ty->circular_offset++;
|
||||||
if (ty->circular_offset >= ty->h)
|
if (ty->circular_offset >= ty->h)
|
||||||
|
@ -95,15 +90,15 @@ _termpty_text_scroll(Termpty *ty, Eina_Bool clear)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cells2 = &(ty->screen[end_y * ty->w]);
|
cells = &(ty->screen[end_y * ty->w]);
|
||||||
for (y = start_y; y < end_y; y++)
|
for (y = start_y; y < end_y; y++)
|
||||||
{
|
{
|
||||||
cells = &(ty->screen[y * ty->w]);
|
cells = &(ty->screen[(y + 1) * ty->w]);
|
||||||
cells2 = &(ty->screen[(y + 1) * ty->w]);
|
cells2 = &(ty->screen[y * ty->w]);
|
||||||
termpty_cell_copy(ty, cells2, cells, ty->w);
|
termpty_cell_copy(ty, cells, cells2, ty->w);
|
||||||
}
|
}
|
||||||
if (clear)
|
if (clear)
|
||||||
_text_clear(ty, cells2, ty->w, 0, EINA_TRUE);
|
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +114,7 @@ _termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
|
||||||
end_y = ty->state.scroll_y2 - 1;
|
end_y = ty->state.scroll_y2 - 1;
|
||||||
}
|
}
|
||||||
DBG("... scroll rev!!!!! [%i->%i]", start_y, end_y);
|
DBG("... scroll rev!!!!! [%i->%i]", start_y, end_y);
|
||||||
|
termio_scroll(ty->obj, 1);
|
||||||
|
|
||||||
if (start_y == 0 && end_y == ty->h - 1)
|
if (start_y == 0 && end_y == ty->h - 1)
|
||||||
{
|
{
|
||||||
|
@ -292,29 +288,29 @@ _termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
|
||||||
break;
|
break;
|
||||||
case TERMPTY_CLR_BEGIN:
|
case TERMPTY_CLR_BEGIN:
|
||||||
if (ty->state.cy > 0)
|
if (ty->state.cy > 0)
|
||||||
{
|
{
|
||||||
// First clear from circular > height, then from 0 to circular
|
// First clear from circular > height, then from 0 to circular
|
||||||
int y = ty->state.cy + ty->circular_offset;
|
int y = ty->state.cy + ty->circular_offset;
|
||||||
|
|
||||||
cells = &(TERMPTY_SCREEN(ty, 0, 0));
|
cells = &(TERMPTY_SCREEN(ty, 0, 0));
|
||||||
|
|
||||||
if (y < ty->h)
|
if (y < ty->h)
|
||||||
{
|
{
|
||||||
_text_clear(ty, cells, ty->w * ty->state.cy, 0, EINA_TRUE);
|
_text_clear(ty, cells, ty->w * ty->state.cy, 0, EINA_TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int yt = y % ty->w;
|
int yt = y % ty->w;
|
||||||
int yb = ty->h - ty->circular_offset;
|
int yb = ty->h - ty->circular_offset;
|
||||||
|
|
||||||
_text_clear(ty, cells, ty->w * yb, 0, EINA_TRUE);
|
_text_clear(ty, cells, ty->w * yb, 0, EINA_TRUE);
|
||||||
_text_clear(ty, ty->screen, ty->w * yt, 0, EINA_TRUE);
|
_text_clear(ty, ty->screen, ty->w * yt, 0, EINA_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_termpty_clear_line(ty, mode, ty->w);
|
_termpty_clear_line(ty, mode, ty->w);
|
||||||
break;
|
break;
|
||||||
case TERMPTY_CLR_ALL:
|
case TERMPTY_CLR_ALL:
|
||||||
ty->circular_offset = 0;
|
ty->circular_offset = 0;
|
||||||
_text_clear(ty, ty->screen, ty->w * ty->h, 0, EINA_TRUE);
|
_text_clear(ty, ty->screen, ty->w * ty->h, 0, EINA_TRUE);
|
||||||
ty->state.scroll_y2 = 0;
|
ty->state.scroll_y2 = 0;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue