Nothing Special   »   [go: up one dir, main page]

Skip to content

Commit

Permalink
textview: Add hacky SetFontSize functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
roblillack committed May 14, 2024
1 parent 57058d9 commit 724ee73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions textview.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ func (textview *TextView) SetText(text string) {
defer C.free(unsafe.Pointer(cText))
C.TextView_SetText(textview.textViewPtr, cText)
}

// SetText sets the text of the text view
func (textview *TextView) SetFontSize(size int) {
C.TextView_SetFontSize(textview.textViewPtr, C.int(size))
}
7 changes: 4 additions & 3 deletions textview.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

@interface TextViewHandler : NSObject

@property (assign) int goTextViewId;
@property(assign) int goTextViewId;

@end

typedef void* TextViewPtr;
typedef void *TextViewPtr;

TextViewPtr TextView_New(int goTextViewId, int x, int y, int w, int h);
void TextView_SetText(TextViewPtr textViewPtr, const char* text);
void TextView_SetText(TextViewPtr textViewPtr, const char *text);
void TextView_SetFontSize(TextViewPtr textViewPtr, int size);
6 changes: 6 additions & 0 deletions textview.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ void TextView_SetText(TextViewPtr textViewPtr, const char* text) {
NSTextView* tv = (NSTextView*)textViewPtr;
[tv setString:[NSString stringWithUTF8String:text]];
}

void TextView_SetFontSize(TextViewPtr textViewPtr, int size) {
NSTextView* tv = (NSTextView*)textViewPtr;
NSFont* font = [NSFont fontWithName:@"Helvetica" size:size];
[tv setFont:font];
}

0 comments on commit 724ee73

Please sign in to comment.