From c818a2abf9fd25681e146e2125b710e6476bb183 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 8 Jun 2021 16:50:30 +0900 Subject: [PATCH] [qwaq] Support base filename and cursor fetching Getting the base filename and the current cursor position is needed for execute-to-line support in the debugger. --- ruamoko/qwaq/editor/editor.h | 4 ++++ ruamoko/qwaq/editor/editor.r | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ruamoko/qwaq/editor/editor.h b/ruamoko/qwaq/editor/editor.h index ec46a6bc0..8f86ef8d7 100644 --- a/ruamoko/qwaq/editor/editor.h +++ b/ruamoko/qwaq/editor/editor.h @@ -21,9 +21,13 @@ Point cursor; unsigned line_count; string filename; + string filepath; } +(Editor *)withRect:(Rect)rect file:(string)filename; ++(Editor *)withRect:(Rect)rect file:(string)filename path:(string)filepath; -(string)filename; +-(string)filepath; +-(Point)cursor; -scrollUp:(unsigned) count; -scrollDown:(unsigned) count; -scrollLeft:(unsigned) count; diff --git a/ruamoko/qwaq/editor/editor.r b/ruamoko/qwaq/editor/editor.r index a3c37a8fc..75f786b9d 100644 --- a/ruamoko/qwaq/editor/editor.r +++ b/ruamoko/qwaq/editor/editor.r @@ -7,13 +7,18 @@ @implementation Editor --initWithRect:(Rect) rect file:(string) filename +-initWithRect:(Rect) rect file:(string) filename path:(string) filepath { if (!(self = [super initWithRect: rect])) { return nil; } self.filename = str_hold (filename); - buffer = [[EditBuffer withFile:filename] retain]; + if (filepath != filename) { + self.filepath = str_hold (filepath); + } else { + self.filepath = filename; + } + buffer = [[EditBuffer withFile:filepath] retain]; line_count = [buffer countLines: {0, [buffer textSize]}]; linebuffer = [[DrawBuffer buffer: { xlen, 1 }] retain]; growMode = gfGrowHi; @@ -25,11 +30,23 @@ +(Editor *)withRect:(Rect)rect file:(string)filename { - return [[[self alloc] initWithRect:rect file:filename] autorelease]; + return [[[self alloc] initWithRect:rect + file:filename + path:filename] autorelease]; +} + ++(Editor *)withRect:(Rect)rect file:(string)filename path:(string)filepath +{ + return [[[self alloc] initWithRect:rect + file:filename + path:filepath] autorelease]; } -(void)dealloc { + if (filepath != filename) { + str_free (filepath); + } str_free (filename); [vScrollBar release]; [buffer release]; @@ -42,6 +59,16 @@ return filename; } +-(string)filepath +{ + return filepath; +} + +-(Point)cursor +{ + return cursor; +} + -draw { [super draw];