mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-14 08:50:58 +00:00
c7597b94d2
Each debugger manages a single target.
122 lines
2.2 KiB
R
122 lines
2.2 KiB
R
#include <QF/keys.h>
|
|
#include "color.h"
|
|
#include "qwaq-editor.h"
|
|
|
|
@implementation Editor
|
|
|
|
-initWithRect:(Rect) rect file:(string) filename
|
|
{
|
|
if (!(self = [super initWithRect: rect])) {
|
|
return nil;
|
|
}
|
|
self.filename = filename;
|
|
buffer = [[EditBuffer alloc] initWithFile: filename];
|
|
line_count = [buffer countLines: {0, [buffer textSize]}];
|
|
linebuffer = [DrawBuffer buffer: { xlen, 1 }];
|
|
growMode = gfGrowHi;
|
|
options = ofCanFocus;
|
|
return self;
|
|
}
|
|
|
|
-(string)filename
|
|
{
|
|
return filename;
|
|
}
|
|
|
|
-draw
|
|
{
|
|
[super draw];
|
|
unsigned lind = base_index;
|
|
int *lbuf = [linebuffer buffer];
|
|
for (int y = 0; y < ylen; y++) {
|
|
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]];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-resize: (Extent) delta
|
|
{
|
|
[super resize: delta];
|
|
[linebuffer resizeTo: {xlen, 1}];
|
|
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];
|
|
}
|
|
}
|
|
} else if (event.what == qe_keydown) {
|
|
switch (event.key.code) {
|
|
case QFK_PAGEUP:
|
|
[self scrollUp: ylen];
|
|
break;
|
|
case QFK_PAGEDOWN:
|
|
[self scrollDown: ylen];
|
|
break;
|
|
}
|
|
}
|
|
event.what = qe_none;
|
|
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
|