From 93b83da51e22dfc40bc772098deb937d38d5b084 Mon Sep 17 00:00:00 2001
From: Piotr Wieczorek
Date: Wed, 17 May 2023 21:40:29 +0200
Subject: [PATCH] More additions by @tomet slightly modified to match the
library's style
---
drawings.cxx | 10 +++-
drawings.go | 14 ++++--
drawings.h | 6 ++-
enumerations.cxx | 3 ++
enumerations.go | 21 ++++----
enumerations.h | 3 ++
event_handler.h | 2 +-
image.go | 18 +++++++
text.cxx | 55 +++++++++++++++++++--
text.go | 124 ++++++++++++++++++++++++++++++++++++++++-------
text.h | 11 +++++
widget.cxx | 3 ++
widget.go | 10 ++--
widget.h | 3 +-
14 files changed, 238 insertions(+), 45 deletions(-)
diff --git a/drawings.cxx b/drawings.cxx
index 7aa7d6b..9a0ff1c 100644
--- a/drawings.cxx
+++ b/drawings.cxx
@@ -11,6 +11,12 @@ void go_fltk_color(unsigned int color) {
void go_fltk_set_draw_font(int font, int size) {
fl_font((Fl_Font)font, size);
}
+int go_fltk_draw_font() {
+ return fl_font();
+}
+int go_fltk_draw_font_size() {
+ return fl_size();
+}
void go_fltk_draw(const char* text, int x, int y, int w, int h, unsigned int align) {
fl_draw(text, x, y, w, h, (Fl_Align)align);
}
@@ -70,7 +76,7 @@ void go_fltk_draw_arrow(int x, int y, int w, int h, int arr, int orient, unsigne
Fl_Rect r{x, y, w, h};
fl_draw_arrow(r, (Fl_Arrow_Type)arr, (Fl_Orientation)orient, color);
}
-
+
void go_fltk_rect_with_color(int x, int y, int w, int h, unsigned int c) {
fl_rect(x, y, w, h, c);
}
@@ -455,4 +461,4 @@ void go_fltk_draw_text2(const char *str, int x, int y, int w, int h, int align)
void go_fltk_draw_check(int x, int y, int w, int h, unsigned int col) {
fl_draw_check(Fl_Rect(x, y, w, h), (Fl_Color)col);
-}
\ No newline at end of file
+}
diff --git a/drawings.go b/drawings.go
index 4dd1dda..af8caf4 100644
--- a/drawings.go
+++ b/drawings.go
@@ -26,6 +26,10 @@ func SetDrawFont(font Font, size int) {
C.go_fltk_set_draw_font(C.int(font), C.int(size))
}
+func DrawFont() (Font, int) {
+ return Font(C.go_fltk_draw_font()), int(C.go_fltk_draw_font_size())
+}
+
func PushClip(x, y, w, h int) {
C.go_fltk_push_clip(C.int(x), C.int(y), C.int(w), C.int(h))
}
@@ -65,11 +69,11 @@ func DrawRectf(x, y, w, h int) {
func DrawRectfWithColor(x, y, w, h int, col Color) {
C.go_fltk_rectf_with_color(C.int(x), C.int(y), C.int(w), C.int(h), C.uint(col))
}
-
-func DrawArrow(x, y, w, h int, arr ArrowType, orient Orientation, col Color) {
- C.go_fltk_draw_arrow(C.int(x), C.int(y), C.int(w), C.int(h), C.int(arr), C.int(orient), C.uint(col))
-}
-
+
+func DrawArrow(x, y, w, h int, arr ArrowType, orient Orientation, col Color) {
+ C.go_fltk_draw_arrow(C.int(x), C.int(y), C.int(w), C.int(h), C.int(arr), C.int(orient), C.uint(col))
+}
+
func DrawLine(x, y, x1, y1 int) {
C.go_fltk_line(C.int(x), C.int(y), C.int(x1), C.int(y1))
}
diff --git a/drawings.h b/drawings.h
index f07e70c..797b147 100644
--- a/drawings.h
+++ b/drawings.h
@@ -8,6 +8,8 @@ extern "C" {
extern void go_fltk_color(unsigned int color);
extern void go_fltk_set_draw_font(int font, int size);
+ extern int go_fltk_draw_font();
+ extern int go_fltk_draw_font_size();
extern void go_fltk_draw(const char* text, int x, int y, int w, int h, unsigned int align);
extern void go_fltk_draw_box(int boxType, int x, int y, int w, int h, unsigned int color);
extern void go_fltk_push_clip(int x, int y, int w, int h);
@@ -26,8 +28,8 @@ extern "C" {
extern void go_fltk_rectf(int x, int y, int w, int h);
extern void go_fltk_rectf_with_color(int x, int y, int w, int h, unsigned int c);
extern void go_fltk_rectf_with_rgb(int x, int y, int w, int h, unsigned char r, unsigned char g,
- unsigned char b);
- extern void go_fltk_draw_arrow(int x, int y, int w, int h, int arr, int orient, unsigned int color);
+ unsigned char b);
+ extern void go_fltk_draw_arrow(int x, int y, int w, int h, int arr, int orient, unsigned int color);
extern void go_fltk_line(int x, int y, int x1, int y1);
extern void go_fltk_line2(int x, int y, int x1, int y1, int x2, int y2);
extern void go_fltk_loop(int x, int y, int x1, int y1, int x2, int y2);
diff --git a/enumerations.cxx b/enumerations.cxx
index 4a6d5da..3a6f59a 100644
--- a/enumerations.cxx
+++ b/enumerations.cxx
@@ -131,6 +131,9 @@ const int go_FL_F9 = FL_F + 9;
const int go_FL_F10 = FL_F + 10;
const int go_FL_F11 = FL_F + 11;
const int go_FL_F12 = FL_F + 12;
+const int go_FL_DELETE = FL_Delete;
+const int go_FL_BACKSPACE = FL_BackSpace;
+const int go_FL_INSERT = FL_Insert;
const int go_FL_RGB = FL_RGB;
const int go_FL_INDEX = FL_INDEX;
diff --git a/enumerations.go b/enumerations.go
index a09c01a..642ddc4 100644
--- a/enumerations.go
+++ b/enumerations.go
@@ -46,15 +46,15 @@ var (
type Orientation int
var (
- ORIENT_NONE = Orientation(C.go_FL_ORIENT_NONE)
- ORIENT_RIGHT = Orientation(C.go_FL_ORIENT_RIGHT)
- ORIENT_NE = Orientation(C.go_FL_ORIENT_NE)
- ORIENT_UP = Orientation(C.go_FL_ORIENT_UP)
- ORIENT_NW = Orientation(C.go_FL_ORIENT_NW)
- ORIENT_LEFT = Orientation(C.go_FL_ORIENT_LEFT)
- ORIENT_SW = Orientation(C.go_FL_ORIENT_SW)
- ORIENT_DOWN = Orientation(C.go_FL_ORIENT_DOWN)
- ORIENT_SE = Orientation(C.go_FL_ORIENT_SE)
+ ORIENT_NONE = Orientation(C.go_FL_ORIENT_NONE)
+ ORIENT_RIGHT = Orientation(C.go_FL_ORIENT_RIGHT)
+ ORIENT_NE = Orientation(C.go_FL_ORIENT_NE)
+ ORIENT_UP = Orientation(C.go_FL_ORIENT_UP)
+ ORIENT_NW = Orientation(C.go_FL_ORIENT_NW)
+ ORIENT_LEFT = Orientation(C.go_FL_ORIENT_LEFT)
+ ORIENT_SW = Orientation(C.go_FL_ORIENT_SW)
+ ORIENT_DOWN = Orientation(C.go_FL_ORIENT_DOWN)
+ ORIENT_SE = Orientation(C.go_FL_ORIENT_SE)
)
type BoxType int
@@ -387,4 +387,7 @@ var (
F10 = int(C.go_FL_F10)
F11 = int(C.go_FL_F11)
F12 = int(C.go_FL_F12)
+ DELETE = int(C.go_FL_DELETE)
+ BACKSPACE = int(C.go_FL_BACKSPACE)
+ INSERT = int(C.go_FL_INSERT)
)
diff --git a/enumerations.h b/enumerations.h
index 0987f0e..3d43863 100644
--- a/enumerations.h
+++ b/enumerations.h
@@ -130,6 +130,9 @@ extern "C" {
extern const int go_FL_F10;
extern const int go_FL_F11;
extern const int go_FL_F12;
+ extern const int go_FL_DELETE;
+ extern const int go_FL_BACKSPACE;
+ extern const int go_FL_INSERT;
extern const int go_FL_RGB;
extern const int go_FL_INDEX;
diff --git a/event_handler.h b/event_handler.h
index dc43ce0..7975cfe 100644
--- a/event_handler.h
+++ b/event_handler.h
@@ -39,7 +39,7 @@ class EventHandler : public BaseWidget, public WidgetWithEventHandler, public Wi
if (m_eventHandlerId >= 0) {
const int ret = _go_eventHandler(m_eventHandlerId, event);
if (ret != 0) {
- return ret;
+ return ret;
}
}
return BaseWidget::handle(event);
diff --git a/image.go b/image.go
index a1d4811..940b4e2 100644
--- a/image.go
+++ b/image.go
@@ -198,6 +198,24 @@ func NewRgbImageFromSvg(img *SvgImage) (*RgbImage) {
return rgbImage
}
+func NewRgbImageFromPng(img *PngImage) (*RgbImage) {
+ rgbImage := &RgbImage{}
+ rgbImage.image = img.image
+ return rgbImage
+}
+
+func NewRgbImageFromBmp(img *BmpImage) (*RgbImage) {
+ rgbImage := &RgbImage{}
+ rgbImage.image = img.image
+ return rgbImage
+}
+
+func NewRgbImageFromJpeg(img *JpegImage) (*RgbImage) {
+ rgbImage := &RgbImage{}
+ rgbImage.image = img.image
+ return rgbImage
+}
+
func NewRgbImageFromImage(image goimage.Image) (*RgbImage, error) {
rgbImage := &RgbImage{}
var w, h, stride, depth int
diff --git a/text.cxx b/text.cxx
index 79ca376..cc2b8f1 100644
--- a/text.cxx
+++ b/text.cxx
@@ -7,12 +7,20 @@
#include
#include "event_handler.h"
+#include "_cgo_export.h"
+// --- Text Display ---
+
class GText_Display : public EventHandler {
public:
- GText_Display(int x, int y, int w, int h, const char* label)
- : EventHandler(x, y, w, h, label) {}
+ GText_Display(int x, int y, int w, int h, const char *label)
+ : EventHandler(x, y, w, h, label) {}
+
+ // make xy_to_position() public
+ int xy_to_position(int x, int y) {
+ return EventHandler::xy_to_position(x, y);
+ }
};
GText_Display *go_fltk_new_TextDisplay(int x, int y, int w, int h, const char *text) {
@@ -27,6 +35,14 @@ void go_fltk_TextDisplay_set_wrap_mode(Fl_Text_Display *d, int wrap, int wrapMar
d->wrap_mode(wrap, wrapMargin);
}
+int go_fltk_TextDisplay_xy_to_position(Fl_Text_Display *d, int x, int y) {
+ return ((GText_Display*) d)->xy_to_position(x, y);
+}
+
+int go_fltk_TextDisplay_position_to_xy(Fl_Text_Display *d, int pos, int *x, int *y) {
+ return d->position_to_xy(pos, x, y);
+}
+
int go_fltk_TextDisplay_move_right(Fl_Text_Display *d) {
return d->move_right();
}
@@ -47,6 +63,10 @@ void go_fltk_TextDisplay_show_insert_position(Fl_Text_Display *d) {
d->show_insert_position();
}
+void go_fltk_TextDisplay_hide_cursor(Fl_Text_Display *d) {
+ d->hide_cursor();
+}
+
unsigned int go_fltk_TextDisplay_text_color(Fl_Text_Display *d) {
return d->textcolor();
}
@@ -83,6 +103,8 @@ void go_fltk_TextDisplay_overstrike(Fl_Text_Display *d, const char* text) {
d->overstrike(text);
}
+// --- Text Editor ---
+
class GText_Editor : public EventHandler {
public:
GText_Editor(int x, int y, int w, int h, const char* label)
@@ -117,6 +139,13 @@ void go_fltk_TextEditor_select_all(Fl_Text_Editor *e) {
Fl_Text_Editor::kf_select_all(0, e);
}
+// --- Text Buffer ---
+
+void modify_callback_handler(int pos, int nInserted, int nDeleted, int nRestyled, const char *deletedText, void *cbArg) {
+ uintptr_t id = (uintptr_t)cbArg;
+ _go_modifyCallbackHandler(id, pos, nInserted, nDeleted, nRestyled, (char*)deletedText);
+}
+
Fl_Text_Buffer *go_fltk_new_TextBuffer(void) {
return new Fl_Text_Buffer;
}
@@ -125,6 +154,10 @@ void go_fltk_TextBuffer_delete(Fl_Text_Buffer* b) {
delete b;
}
+void go_fltk_TextBuffer_add_modify_callback(Fl_Text_Buffer *b, uintptr_t handlerId) {
+ b->add_modify_callback(modify_callback_handler, (void*)handlerId);
+}
+
void go_fltk_TextBuffer_set_text(Fl_Text_Buffer *b, const char *txt) {
b->text(txt);
}
@@ -133,6 +166,22 @@ void go_fltk_TextBuffer_append(Fl_Text_Buffer *b, const char *txt) {
b->append(txt);
}
+unsigned int go_fltk_TextBuffer_char_at(Fl_Text_Buffer *b, int pos) {
+ return b->char_at(pos);
+}
+
+int go_fltk_TextBuffer_next_char(Fl_Text_Buffer *b, int ix) {
+ return b->next_char(ix);
+}
+
+int go_fltk_TextBuffer_prev_char(Fl_Text_Buffer *b, int ix) {
+ return b->prev_char(ix);
+}
+
+int go_fltk_TextBuffer_length(Fl_Text_Buffer *b) {
+ return b->length();
+}
+
const char *go_fltk_TextBuffer_text(Fl_Text_Buffer *b) {
return b->text();
}
@@ -202,4 +251,4 @@ void go_fltk_TextDisplay_set_highlight_data(Fl_Text_Display *self, Fl_Text_Buffe
stable[i] = (Fl_Text_Display::Style_Table_Entry){color[i], font[i], fontsz[i], attr[i], bgcolor[i]};
}
self->highlight_data(sbuff, stable, sz, 'A', 0, 0);
-}
\ No newline at end of file
+}
diff --git a/text.go b/text.go
index 7c371b5..8cfb0cc 100644
--- a/text.go
+++ b/text.go
@@ -2,6 +2,7 @@ package fltk
/*
#include
+#include
#include "text.h"
*/
import "C"
@@ -10,6 +11,50 @@ import (
"unsafe"
)
+// --- Modify-Callback-Map ---
+
+type modifyCallbackMap struct {
+ cbMap map[uintptr]func(int, int, int, int, string)
+ id uintptr
+}
+
+func newModifyCallbackMap() *modifyCallbackMap {
+ return &modifyCallbackMap{
+ cbMap: make(map[uintptr]func(int, int, int, int, string)),
+ }
+}
+func (m *modifyCallbackMap) register(fn func(int, int, int, int, string)) uintptr {
+ m.id++
+ m.cbMap[m.id] = fn
+ return m.id
+}
+func (m *modifyCallbackMap) unregister(id uintptr) {
+ delete(m.cbMap, id)
+}
+func (m *modifyCallbackMap) invoke(id uintptr, pos, nInserted, nDeleted, nRestyled int, deletedText string) {
+ if callback, ok := m.cbMap[id]; ok && callback != nil {
+ callback(pos, nInserted, nDeleted, nRestyled, deletedText)
+ }
+}
+func (m *modifyCallbackMap) isEmpty() bool {
+ return len(m.cbMap) == 0
+}
+func (m *modifyCallbackMap) size() int {
+ return len(m.cbMap)
+}
+func (m *modifyCallbackMap) clear() {
+ for id := range m.cbMap {
+ delete(m.cbMap, id)
+ }
+}
+
+var globalModifyCallbackMap = newModifyCallbackMap()
+
+//export _go_modifyCallbackHandler
+func _go_modifyCallbackHandler(id C.uintptr_t, pos, nInserted, nDeleted, nRestyled C.int, deletedText *C.char) {
+ globalModifyCallbackMap.invoke(uintptr(id), int(pos), int(nInserted), int(nDeleted), int(nRestyled), C.GoString(deletedText))
+}
+
type StyleTableEntry struct {
Color Color
Font Font
@@ -17,14 +62,15 @@ type StyleTableEntry struct {
}
type TextBuffer struct {
- cPtr *C.Fl_Text_Buffer
+ cPtr *C.Fl_Text_Buffer
+ handlerIds []uintptr
}
var ErrTextBufferDestroyed = errors.New("text buffer is destroyed")
func NewTextBuffer() *TextBuffer {
ptr := C.go_fltk_new_TextBuffer()
- return &TextBuffer{ptr}
+ return &TextBuffer{cPtr: ptr}
}
func (b *TextBuffer) ptr() *C.Fl_Text_Buffer {
@@ -34,6 +80,11 @@ func (b *TextBuffer) ptr() *C.Fl_Text_Buffer {
return b.cPtr
}
func (b *TextBuffer) Destroy() {
+ for _, id := range b.handlerIds {
+ globalModifyCallbackMap.unregister(id)
+ }
+ b.handlerIds = nil
+
C.go_fltk_TextBuffer_delete(b.ptr())
b.cPtr = nil
}
@@ -50,6 +101,28 @@ func (b *TextBuffer) Append(txt string) {
C.go_fltk_TextBuffer_append(b.ptr(), txtstr)
}
+func (b *TextBuffer) CharAt(pos int) rune {
+ return rune(C.go_fltk_TextBuffer_char_at(b.ptr(), C.int(pos)))
+}
+
+func (b *TextBuffer) NextChar(pos int) int {
+ return int(C.go_fltk_TextBuffer_next_char(b.ptr(), C.int(pos)))
+}
+
+func (b *TextBuffer) PrevChar(pos int) int {
+ return int(C.go_fltk_TextBuffer_prev_char(b.ptr(), C.int(pos)))
+}
+
+func (b *TextBuffer) Length() int {
+ return int(C.go_fltk_TextBuffer_length(b.ptr()))
+}
+
+func (b *TextBuffer) AddModifyCallback(cb func(int, int, int, int, string)) {
+ handlerId := globalModifyCallbackMap.register(cb)
+ b.handlerIds = append(b.handlerIds, handlerId)
+ C.go_fltk_TextBuffer_add_modify_callback(b.ptr(), C.uintptr_t(handlerId))
+}
+
func (b *TextBuffer) Text() string {
cStr := C.go_fltk_TextBuffer_text(b.ptr())
defer C.free(unsafe.Pointer(cStr))
@@ -194,9 +267,21 @@ func (t *TextDisplay) SetWrapMode(wrap WrapMode, wrapMargin ...int) {
C.go_fltk_TextDisplay_set_wrap_mode((*C.Fl_Text_Display)(t.ptr()), C.int(wrap), C.int(wrapMargin[0]))
}
+// Translate a pixel position into a character index.
+func (t *TextDisplay) XYToPosition(x, y int) int {
+ return int(C.go_fltk_TextDisplay_xy_to_position((*C.Fl_Text_Display)(t.ptr()), C.int(x), C.int(y)))
+}
+
+// Convert a character index into a pixel position.
+func (t *TextDisplay) PositionToXY(pos int) (int, int) {
+ var x, y C.int
+ C.go_fltk_TextDisplay_position_to_xy((*C.Fl_Text_Display)(t.ptr()), C.int(pos), &x, &y)
+ return int(x), int(y)
+}
+
func (t *TextDisplay) Buffer() *TextBuffer {
ptr := C.go_fltk_TextDisplay_buffer((*C.Fl_Text_Display)(t.ptr()))
- return &TextBuffer{ptr}
+ return &TextBuffer{cPtr: ptr}
}
// MoveRight moves the current insert position right one character.
@@ -225,37 +310,42 @@ func (t *TextDisplay) ShowInsertPosition() {
C.go_fltk_TextDisplay_show_insert_position((*C.Fl_Text_Display)(t.ptr()))
}
-// TextColor gets the default color of text in the widget
+// HideCursor hides the text cursor.
+func (t *TextDisplay) HideCursor() {
+ C.go_fltk_TextDisplay_hide_cursor((*C.Fl_Text_Display)(t.ptr()))
+}
+
+// TextColor gets the default color of text in the widget.
func (t *TextDisplay) TextColor() Color {
return Color(C.go_fltk_TextDisplay_text_color((*C.Fl_Text_Display)(t.ptr())))
}
-// SetTextColor sets the default color of text in the widget
+// SetTextColor sets the default color of text in the widget.
func (t *TextDisplay) SetTextColor(color Color) {
C.go_fltk_TextDisplay_set_text_color((*C.Fl_Text_Display)(t.ptr()), C.uint(color))
}
-// TextSize gets the default size of text in the widget
+// TextSize gets the default size of text in the widget.
func (t *TextDisplay) TextSize() int {
return (int)(C.go_fltk_TextDisplay_text_size((*C.Fl_Text_Display)(t.ptr())))
}
-// SetTextSize sets the default size of text in the widget
+// SetTextSize sets the default size of text in the widget.
func (t *TextDisplay) SetTextSize(size int) {
C.go_fltk_TextDisplay_set_text_size((*C.Fl_Text_Display)(t.ptr()), C.int(size))
}
-// SetInsertPosition set the insert position to a new position
+// SetInsertPosition set the insert position to a new position.
func (t *TextDisplay) SetInsertPosition(newPos int) {
C.go_fltk_TextDisplay_insert_position((*C.Fl_Text_Display)(t.ptr()), C.int(newPos))
}
-// GetInsertPosition - return the current insert position
+// GetInsertPosition - return the current insert position.
func (t *TextDisplay) GetInsertPosition() int {
return (int)(C.go_fltk_TextDisplay_get_insert_position((*C.Fl_Text_Display)(t.ptr())))
}
-// InsertText - Insert text at the cursor position
+// InsertText - Insert text at the cursor position.
func (t *TextDisplay) InsertText(txt string) {
txtstr := C.CString(txt)
defer C.free(unsafe.Pointer(txtstr))
@@ -289,12 +379,12 @@ type TextEditor struct {
TextDisplay
}
-// Copy copy of selected text or the current character in the current buffer of editor 'e'. (kf_copy)
+// Copy copy of selected text or the current character in the current buffer of the editor (kf_copy)
func (t *TextEditor) Copy() {
C.go_fltk_TextEditor_copy((*C.Fl_Text_Editor)(t.ptr()))
}
-// Insert - Togglesthe insert mode (kf_insert)
+// Insert toggles the insert mode (kf_insert)
func (t *TextEditor) Insert() {
C.go_fltk_TextEditor_insert((*C.Fl_Text_Editor)(t.ptr()))
}
@@ -318,11 +408,11 @@ func (t *TextEditor) SelectAll() {
// NewTextEditor returns a TextEditor.
//
// Example:
-// textBuffer := fltk.NewTextBuffer()
-// textEditor := fltk.NewTextEditor(x, y, width, height)
-// textEditor.SetBuffer(textBuffer)
-// textBuffer.SetText("Initial Text")
-// fmt.Println(textBuffer.Text()) // Prints: Initial Text
+// textBuffer := fltk.NewTextBuffer()
+// textEditor := fltk.NewTextEditor(x, y, width, height)
+// textEditor.SetBuffer(textBuffer)
+// textBuffer.SetText("Initial Text")
+// fmt.Println(textBuffer.Text()) // Prints: Initial Text
//
// Note that the text buffer pointer must be kept around for as long as the
// text editor is in use.
diff --git a/text.h b/text.h
index c64ca7e..e3360a7 100644
--- a/text.h
+++ b/text.h
@@ -1,5 +1,8 @@
#pragma once
+#include
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -20,11 +23,14 @@ extern "C" {
extern GText_Display *go_fltk_new_TextDisplay(int x, int y, int w, int h, const char *text);
extern void go_fltk_TextDisplay_set_buffer(Fl_Text_Display *d, Fl_Text_Buffer *buf);
extern void go_fltk_TextDisplay_set_wrap_mode(Fl_Text_Display *d, int wrap, int wrapMargin);
+ extern int go_fltk_TextDisplay_xy_to_position(Fl_Text_Display *d, int x, int y);
+ extern int go_fltk_TextDisplay_position_to_xy(Fl_Text_Display *d, int pos, int *x, int *y);
extern int go_fltk_TextDisplay_move_right(Fl_Text_Display *d);
extern int go_fltk_TextDisplay_move_left(Fl_Text_Display *d);
extern int go_fltk_TextDisplay_move_up(Fl_Text_Display *d);
extern int go_fltk_TextDisplay_move_down(Fl_Text_Display *d);
extern void go_fltk_TextDisplay_show_insert_position(Fl_Text_Display *d);
+ extern void go_fltk_TextDisplay_hide_cursor(Fl_Text_Display *d);
extern unsigned int go_fltk_TextDisplay_text_color(Fl_Text_Display *d);
extern void go_fltk_TextDisplay_set_text_color(Fl_Text_Display* d, unsigned int color);
extern int go_fltk_TextDisplay_text_size(Fl_Text_Display *d);
@@ -36,9 +42,14 @@ extern "C" {
extern void go_fltk_TextDisplay_overstrike(Fl_Text_Display *d, const char* text);
extern Fl_Text_Buffer *go_fltk_new_TextBuffer(void);
+ extern void go_fltk_TextBuffer_add_modify_callback(Fl_Text_Buffer *b, uintptr_t handlerId);
extern void go_fltk_TextBuffer_delete(Fl_Text_Buffer* b);
extern void go_fltk_TextBuffer_set_text(Fl_Text_Buffer *b, const char *txt);
extern void go_fltk_TextBuffer_append(Fl_Text_Buffer *b, const char *txt);
+ extern unsigned int go_fltk_TextBuffer_char_at(Fl_Text_Buffer *b, int pos);
+ extern int go_fltk_TextBuffer_next_char(Fl_Text_Buffer *b, int ix);
+ extern int go_fltk_TextBuffer_prev_char(Fl_Text_Buffer *b, int ix);
+ extern int go_fltk_TextBuffer_length(Fl_Text_Buffer *b);
extern const char *go_fltk_TextBuffer_text(Fl_Text_Buffer *b);
extern const char *go_fltk_TextBuffer_text_range(Fl_Text_Buffer *b, int start, int end);
extern void go_fltk_TextBuffer_highlight(Fl_Text_Buffer *b, int start, int end);
diff --git a/widget.cxx b/widget.cxx
index 217ea25..36fe8d5 100644
--- a/widget.cxx
+++ b/widget.cxx
@@ -112,6 +112,9 @@ void go_fltk_Widget_deactivate(Fl_Widget* w) {
void go_fltk_Widget_activate(Fl_Widget* w) {
w->activate();
}
+unsigned int go_fltk_Widget_active(Fl_Widget* w) {
+ return w->active();
+}
void go_fltk_Widget_set_type(Fl_Widget* w, unsigned char type) {
w->type(type);
}
diff --git a/widget.go b/widget.go
index 99e62d0..a097c2b 100644
--- a/widget.go
+++ b/widget.go
@@ -167,6 +167,7 @@ func (w *widget) Resize(x, y, width, height int) {
}
func (w *widget) Redraw() { C.go_fltk_Widget_redraw(w.ptr()) }
func (w *widget) Deactivate() { C.go_fltk_Widget_deactivate(w.ptr()) }
+func (w *widget) IsActive() bool { return C.go_fltk_Widget_active(w.ptr()) != 0 }
func (w *widget) Activate() { C.go_fltk_Widget_activate(w.ptr()) }
func (w *widget) SetType(widgetType uint8) { C.go_fltk_Widget_set_type(w.ptr(), C.uchar(widgetType)) }
func (w *widget) Show() { C.go_fltk_Widget_show(w.ptr()) }
@@ -211,11 +212,10 @@ func (w *widget) Parent() *Group {
}
func (w *widget) TakeFocus() int {
return int(C.go_fltk_Widget_take_focus(w.ptr()))
-}
-func (w *widget) HasFocus() bool {
- res := int(C.go_fltk_Widget_has_focus(w.ptr()))
- return res != 0
-}
+}
+func (w *widget) HasFocus() bool {
+ return C.go_fltk_Widget_has_focus(w.ptr()) != 0
+}
func (w *widget) Changed() uint {
return uint(C.go_fltk_Widget_changed(w.ptr()))
diff --git a/widget.h b/widget.h
index ebb9075..88ab0b4 100644
--- a/widget.h
+++ b/widget.h
@@ -39,7 +39,8 @@ extern "C" {
extern void go_fltk_Widget_resize(Fl_Widget* w, int x, int y, int width, int height);
extern void go_fltk_Widget_redraw(Fl_Widget* w);
extern void go_fltk_Widget_deactivate(Fl_Widget* w);
- extern void go_fltk_Widget_activate(Fl_Widget* w);
+ extern void go_fltk_Widget_activate(Fl_Widget *w);
+ extern unsigned int go_fltk_Widget_active(Fl_Widget* w);
extern void go_fltk_Widget_set_type(Fl_Widget* w, unsigned char type);
extern void go_fltk_Widget_show(Fl_Widget* w);
extern void go_fltk_Widget_hide(Fl_Widget* w);