mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[qwaq] Implement scrolling via mouse wheel
Line formatting segs when scrolling horizontally through a tab, but... things ware working nicely.
This commit is contained in:
parent
8694798943
commit
16c60655e7
2 changed files with 72 additions and 1 deletions
|
@ -13,12 +13,17 @@
|
|||
eb_sel_t selection;
|
||||
unsigned base_index; // top left corner
|
||||
unsigned line_index; // current line
|
||||
unsigned x_index; // horizontal scrolling
|
||||
unsigned char_index; // current character
|
||||
unsigned old_cind; // previous character
|
||||
Point cursor;
|
||||
unsigned line_count;
|
||||
}
|
||||
-initWithRect:(Rect) rect file:(string) filename;
|
||||
-scrollUp:(unsigned) count;
|
||||
-scrollDown:(unsigned) count;
|
||||
-scrollLeft:(unsigned) count;
|
||||
-scrollRight:(unsigned) count;
|
||||
@end
|
||||
|
||||
#endif//__qwaq_editor_h
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
|
||||
-draw
|
||||
{
|
||||
[super draw];
|
||||
unsigned lind = base_index;
|
||||
int *lbuf = [linebuffer buffer];
|
||||
for (int y = 0; y < ylen; y++) {
|
||||
lind = [buffer formatLine:lind from:0 into:lbuf width:xlen
|
||||
lind = [buffer formatLine:lind from:x_index into:lbuf width:xlen
|
||||
highlight:selection colors: {COLOR_PAIR (1), COLOR_PAIR(2)}];
|
||||
[textContext blitFromBuffer: linebuffer to: {xpos, ypos + y}
|
||||
from: [linebuffer rect]];
|
||||
|
@ -27,4 +28,69 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-handleEvent:(qwaq_event_t *) event
|
||||
{
|
||||
if (event.what & qe_mouse) {
|
||||
if (event.what == qe_mouseclick) {
|
||||
if (event.mouse.buttons & (1 << 3)) {
|
||||
[self scrollUp: 1];
|
||||
}
|
||||
if (event.mouse.buttons & (1 << 4)) {
|
||||
[self scrollDown: 1];
|
||||
}
|
||||
if (event.mouse.buttons & (1 << 5)) {
|
||||
[self scrollLeft: 1];
|
||||
}
|
||||
if (event.mouse.buttons & (1 << 6)) {
|
||||
[self scrollRight: 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-scrollUp:(unsigned) count
|
||||
{
|
||||
if (count == 1) {
|
||||
base_index = [buffer prevLine: base_index];
|
||||
} else {
|
||||
base_index = [buffer prevLine: base_index :count];
|
||||
}
|
||||
[self redraw];
|
||||
return self;
|
||||
}
|
||||
|
||||
-scrollDown:(unsigned) count
|
||||
{
|
||||
if (count == 1) {
|
||||
base_index = [buffer nextLine: base_index];
|
||||
} else {
|
||||
base_index = [buffer nextLine: base_index :count];
|
||||
}
|
||||
[self redraw];
|
||||
return self;
|
||||
}
|
||||
|
||||
-scrollLeft:(unsigned) count
|
||||
{
|
||||
if (x_index > count) {
|
||||
x_index -= count;
|
||||
} else {
|
||||
x_index = 0;
|
||||
}
|
||||
[self redraw];
|
||||
return self;
|
||||
}
|
||||
|
||||
-scrollRight:(unsigned) count
|
||||
{
|
||||
if (1024 - x_index > count) {
|
||||
x_index += count;
|
||||
} else {
|
||||
x_index = 1024;
|
||||
}
|
||||
[self redraw];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue