mirror of
https://github.com/tmux/tmux.git
synced 2025-01-27 16:48:49 +00:00
Scroll data should be per-window not global.
This commit is contained in:
parent
9a6e47cfa8
commit
c424ef37d0
4
tmux.h
4
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.85 2007-11-21 13:11:41 nicm Exp $ */
|
/* $Id: tmux.h,v 1.86 2007-11-21 14:01:53 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -448,7 +448,9 @@ struct window {
|
|||||||
#define WINDOW_BELL 0x1
|
#define WINDOW_BELL 0x1
|
||||||
|
|
||||||
struct screen screen;
|
struct screen screen;
|
||||||
|
|
||||||
const struct window_mode *mode;
|
const struct window_mode *mode;
|
||||||
|
void *modedata;
|
||||||
|
|
||||||
u_int references;
|
u_int references;
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: window-scroll.c,v 1.1 2007-11-21 13:11:41 nicm Exp $ */
|
/* $Id: window-scroll.c,v 1.2 2007-11-21 14:01:53 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -32,14 +32,19 @@ const struct window_mode window_scroll_mode = {
|
|||||||
window_scroll_key
|
window_scroll_key
|
||||||
};
|
};
|
||||||
|
|
||||||
u_int window_scroll_offset;
|
struct window_scroll_mode_data {
|
||||||
u_int window_scroll_size;
|
u_int off;
|
||||||
|
u_int size;
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
window_scroll_init(struct window *w)
|
window_scroll_init(struct window *w)
|
||||||
{
|
{
|
||||||
window_scroll_offset = 0;
|
struct window_scroll_mode_data *data;
|
||||||
window_scroll_size = w->screen.hsize;
|
|
||||||
|
w->modedata = data = xmalloc(sizeof *data);
|
||||||
|
data->off = 0;
|
||||||
|
data->size = w->screen.hsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -50,16 +55,17 @@ window_scroll_resize(struct window *w, u_int sx, u_int sy)
|
|||||||
void
|
void
|
||||||
window_scroll_draw(struct window *w, struct buffer *b, u_int py, u_int ny)
|
window_scroll_draw(struct window *w, struct buffer *b, u_int py, u_int ny)
|
||||||
{
|
{
|
||||||
struct screen *s = &w->screen;
|
struct window_scroll_mode_data *data = w->modedata;
|
||||||
char buf[32];
|
struct screen *s = &w->screen;
|
||||||
size_t len;
|
char buf[32];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (s->hsize != window_scroll_size) {
|
if (s->hsize != data->size) {
|
||||||
window_scroll_offset += s->hsize - window_scroll_size;
|
data->off += s->hsize - data->size;
|
||||||
window_scroll_size = s->hsize;
|
data->size = s->hsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_draw(s, b, py, ny, window_scroll_offset);
|
screen_draw(s, b, py, ny, data->off);
|
||||||
input_store_zero(b, CODE_CURSOROFF);
|
input_store_zero(b, CODE_CURSOROFF);
|
||||||
|
|
||||||
if (py == 0 && ny > 0) {
|
if (py == 0 && ny > 0) {
|
||||||
@ -67,7 +73,7 @@ window_scroll_draw(struct window *w, struct buffer *b, u_int py, u_int ny)
|
|||||||
if (len > (sizeof buf) - 1)
|
if (len > (sizeof buf) - 1)
|
||||||
len = (sizeof buf) - 1;
|
len = (sizeof buf) - 1;
|
||||||
len = xsnprintf(buf, len + 1, "{%u/%u}",
|
len = xsnprintf(buf, len + 1, "{%u/%u}",
|
||||||
window_scroll_offset, s->hsize);
|
data->off, s->hsize);
|
||||||
|
|
||||||
input_store_two(
|
input_store_two(
|
||||||
b, CODE_CURSORMOVE, 0, screen_size_x(s) - len + 1);
|
b, CODE_CURSORMOVE, 0, screen_size_x(s) - len + 1);
|
||||||
@ -79,43 +85,46 @@ window_scroll_draw(struct window *w, struct buffer *b, u_int py, u_int ny)
|
|||||||
void
|
void
|
||||||
window_scroll_key(struct window *w, int key)
|
window_scroll_key(struct window *w, int key)
|
||||||
{
|
{
|
||||||
u_int sy = screen_size_y(&w->screen);
|
struct window_scroll_mode_data *data = w->modedata;
|
||||||
|
u_int sy = screen_size_y(&w->screen);
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'Q':
|
case 'Q':
|
||||||
case 'q':
|
case 'q':
|
||||||
w->mode = NULL;
|
w->mode = NULL;
|
||||||
|
xfree(w->modedata);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_redraw_window_all(w);
|
server_redraw_window_all(w);
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
case 'K':
|
case 'K':
|
||||||
case KEYC_UP:
|
case KEYC_UP:
|
||||||
if (window_scroll_offset < window_scroll_size)
|
if (data->off < data->size)
|
||||||
window_scroll_offset++;
|
data->off++;
|
||||||
server_redraw_window_all(w);
|
server_redraw_window_all(w);
|
||||||
break;
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
case 'J':
|
case 'J':
|
||||||
case KEYC_DOWN:
|
case KEYC_DOWN:
|
||||||
if (window_scroll_offset > 0)
|
if (data->off > 0)
|
||||||
window_scroll_offset--;
|
data->off--;
|
||||||
server_redraw_window_all(w);
|
server_redraw_window_all(w);
|
||||||
break;
|
break;
|
||||||
case '\025':
|
case '\025':
|
||||||
case KEYC_PPAGE:
|
case KEYC_PPAGE:
|
||||||
if (window_scroll_offset + sy > window_scroll_size)
|
if (data->off + sy > data->size)
|
||||||
window_scroll_offset = window_scroll_size;
|
data->off = data->size;
|
||||||
else
|
else
|
||||||
window_scroll_offset += sy;
|
data->off += sy;
|
||||||
server_redraw_window_all(w);
|
server_redraw_window_all(w);
|
||||||
break;
|
break;
|
||||||
case '\006':
|
case '\006':
|
||||||
case KEYC_NPAGE:
|
case KEYC_NPAGE:
|
||||||
if (window_scroll_offset < sy)
|
if (data->off < sy)
|
||||||
window_scroll_offset = 0;
|
data->off = 0;
|
||||||
else
|
else
|
||||||
window_scroll_offset -= sy;
|
data->off -= sy;
|
||||||
server_redraw_window_all(w);
|
server_redraw_window_all(w);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user