diff options
Diffstat (limited to 'redo/table_darwin.m')
| -rw-r--r-- | redo/table_darwin.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/redo/table_darwin.m b/redo/table_darwin.m index 45e9b0b..7fdef24 100644 --- a/redo/table_darwin.m +++ b/redo/table_darwin.m @@ -14,6 +14,24 @@ @end @implementation goTableDataSource + +- (NSInteger)numberOfRowsInTableView:(NSTableView *)view +{ + return (NSInteger) goTableDataSource_getRowCount(self->gotable); +} + +- (id)tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)col row:(NSInteger)row +{ + char *str; + NSString *s; + + // TODO there has to be a better way to get the column index + str = goTableDataSource_getValue(self->gotable, (intptr_t) row, (intptr_t) [[view tableColumns] indexOfObject:col]); + s = [NSString stringWithUTF8String:str]; + free(str); // allocated with C.CString() on the Go side + return s; +} + @end id newTable(void) @@ -59,3 +77,12 @@ id newScrollView(id content) [sv setDocumentView:toNSView(content)]; return (id) sv; } + +void tableMakeDataSource(id table, void *gotable) +{ + goTableDataSource *model; + + model = [goTableDataSource new]; + model->gotable = gotable; + [toNSTableView(table) setDataSource:model]; +} |
