[qwaq] Add a scroll bar to the debug source window

It's not quite hooked up properly yet (Editor ignores the message), but
it did help get ScrollBar displaying properly.
This commit is contained in:
Bill Currie 2020-03-30 22:02:58 +09:00
parent 02f8cc9760
commit b8005a99c9
4 changed files with 34 additions and 7 deletions

View file

@ -9,6 +9,7 @@
@class ProxyView;
@class Editor;
@class ScrollBar;
@class Window;
@class Array;
@ -22,6 +23,7 @@
Editor *current_file;
Window *locals_window;
ScrollBar *scrollbar;
LocalsView *locals_view;
}
+(Debugger *)withTarget:(qdb_target_t)target;

View file

@ -6,6 +6,7 @@
#include "ui/curses.h"
#include "ui/listener.h"
#include "ui/proxyview.h"
#include "ui/scrollbar.h"
#include "ui/window.h"
#include "debugger/debugger.h"
#include "debugger/typeencodings.h"
@ -30,10 +31,14 @@
}
self.target = target;
Extent s = [application size];
files = [[Array array] retain];
source_window = [Window withRect: {nil, [application size]}];
source_window = [Window withRect: {nil, s}];
[application addView:source_window];
scrollbar = [ScrollBar vertical:s.height - 2 at:{s.width - 1, 1}];
[source_window insert:scrollbar];
return self;
}

View file

@ -7,11 +7,13 @@
@class Editor;
@class EditBuffer;
@class ListenerGroup;
@class ScrollBar;
@interface Editor : View
{
EditBuffer *buffer;
DrawBuffer *linebuffer;
ScrollBar *vScrollBar;
eb_sel_t selection;
unsigned base_index; // top left corner
unsigned line_index; // current line
@ -23,7 +25,7 @@
string filename;
}
+(Editor *)withRect:(Rect)rect file:(string)filename;
-initWithRect:(Rect) rect file:(string) filename;
-setVerticalScrollBar:(ScrollBar *)scrollbar;
-(string)filename;
-scrollUp:(unsigned) count;
-scrollDown:(unsigned) count;

View file

@ -2,14 +2,10 @@
#include "qwaq-app.h"
#include "editor/editor.h"
#include "ui/listener.h"
#include "ui/scrollbar.h"
@implementation Editor
+(Editor *)withRect:(Rect)rect file:(string)filename
{
return [[[self alloc] initWithRect:rect file:filename] autorelease];
}
-initWithRect:(Rect) rect file:(string) filename
{
if (!(self = [super initWithRect: rect])) {
@ -24,8 +20,30 @@
return self;
}
+(Editor *)withRect:(Rect)rect file:(string)filename
{
return [[[self alloc] initWithRect:rect file:filename] autorelease];
}
-(void)onScroll:(id)sender
{
}
-setVerticalScrollBar:(ScrollBar *)scrollbar
{
[scrollbar retain];
[[vScrollBar onScroll] removeListener:self :@selector(onScroll)];
[vScrollBar release];
vScrollBar = scrollbar;
[vScrollBar setRange:line_count];
[[vScrollBar onScroll] addListener:self :@selector(onScroll)];
return self;
}
-(void)dealloc
{
[vScrollBar release];
[buffer release];
[linebuffer release];
[super dealloc];