Skip to content

Commit

Permalink
Implemented Utf8Char (read-only)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgriffitts committed Dec 25, 2023
1 parent 3774f22 commit 9b1ae58
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fltk
Submodule fltk updated 49 files
+5 −0 CMake/fl_create_example.cmake
+14 −6 CMake/options.cmake
+16 −10 CMakeLists.txt
+13 −13 CREDITS.txt
+1 −1 FL/Fl_Image_Surface.H
+93 −11 FL/Fl_Menu_Item.H
+44 −37 FL/Fl_Multi_Label.H
+1 −1 FL/Fl_Plugin.H
+3 −2 FL/forms.H
+7 −0 FL/x11.H
+59 −10 README.Wayland.txt
+26 −15 README.txt
+46 −17 configure.ac
+4 −0 documentation/src/osissues.dox
+1 −1 documentation/src/wayland.dox
+29 −16 examples/howto-menu-with-images.cxx
+10 −1 fl_config.cmake.in
+10 −1 fl_config.in
+2 −2 fltk-options/Makefile
+2 −4 fluid/Makefile
+4 −4 fluid/alignment_panel.cxx
+4 −4 fluid/alignment_panel.fl
+9 −4 fluid/makedepend
+3 −3 fluid/widget_panel.cxx
+3 −3 fluid/widget_panel.fl
+1 −1 lib/README.txt
+20 −12 src/CMakeLists.txt
+2 −2 src/Fl_Help_View.cxx
+5 −5 src/Fl_Image_Surface.cxx
+6 −3 src/Fl_Input.cxx
+27 −2 src/Fl_Menu_.cxx
+54 −1 src/Fl_Multi_Label.cxx
+8 −4 src/Fl_Preferences.cxx
+2 −2 src/Fl_Shared_Image.cxx
+11 −6 src/Fl_Text_Display.cxx
+3 −2 src/Fl_x.cxx
+6 −6 src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx
+2 −2 src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
+1 −1 src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H
+1 −1 src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
+9 −3 src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+1 −1 src/drivers/Wayland/Fl_Wayland_Window_Driver.H
+3 −3 src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
+3 −0 src/drivers/X11/Fl_X11_Screen_Driver.cxx
+1 −1 src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
+2 −6 src/makedepend
+9 −1 test/CMakeLists.txt
+8 −8 test/device.cxx
+97 −91 test/forms.cxx
15 changes: 15 additions & 0 deletions include/cfl_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,21 @@ void Fl_Terminal_set_text_size(Fl_Terminal *self, int set);

const char *Fl_Terminal_selection_text(const Fl_Terminal *self);


// typedef struct Fl_Terminal_Derived::Utf8Char Fl_Terminal_Utf8Char;
typedef void Fl_Terminal_Utf8Char;

// Fl_Native_File_Chooser *Fl_Native_File_Chooser_new(int);

// void Fl_Native_File_Chooser_delete(Fl_Native_File_Chooser *self);

const unsigned char *Fl_Terminal_Utf8Char_text_utf8(Fl_Terminal_Utf8Char *self);

int Fl_Terminal_Utf8Char_length(Fl_Terminal_Utf8Char *self);

Fl_Terminal_Utf8Char *Fl_Terminal_Utf8Char_new_obj(char c);


GROUP_DECLARE(Fl_Terminal)

#ifdef __cplusplus
Expand Down
46 changes: 44 additions & 2 deletions src/cfl_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <FL/fl_draw.H>

#include <stdarg.h>
#include <stdlib.h>

WIDGET_CLASS(Fl_Group)

Expand Down Expand Up @@ -328,8 +329,24 @@ struct Fl_Terminal_Derived : public Widget_Derived<Fl_Terminal> {
const char *get_selection_text() const {
return this->selection_text();
}

struct Utf8Char {
/// Temp stub: create a Utf8Char for testing
static Fl_Terminal::Utf8Char * new_obj(char c) {
auto x = new Fl_Terminal::Utf8Char;
auto cs = Fl_Terminal::CharStyle(false);
x->text_ascii(c, cs);
return x;
};
const char* text_utf8(void) const { return ((Fl_Terminal::Utf8Char *) this)->text_utf8(); };
unsigned char length(void) const { return ((Fl_Terminal::Utf8Char *) this)->length(); };
};
};

// struct Utf8Char: public Fl_Terminal_Derived::Utf8Char {

// };

WIDGET_DEFINE(Fl_Terminal)

void Fl_Terminal_set_ansi(Fl_Terminal *self, int boolean) {
Expand Down Expand Up @@ -491,7 +508,7 @@ void Fl_Terminal_set_margin_top(Fl_Terminal *self, int set) {
unsigned Fl_Terminal_output_translate(Fl_Terminal *self) {// Returns OutFlags
LOCK(auto ret = self->output_translate());
return ret;
}
}

void Fl_Terminal_set_output_translate(Fl_Terminal *self, unsigned set) {
LOCK(self->output_translate((Fl_Terminal::OutFlags) set));
Expand Down Expand Up @@ -660,7 +677,7 @@ const char *Fl_Terminal_selection_text(const Fl_Terminal *self) {
return ret;
}

/// vprintf not used by Rust but might be useful for C programs using this
/// printf not used by Rust but might be useful for C programs using this
/// interface
void Fl_Terminal_printf(Fl_Terminal *self, const char *fmt, ...) {
va_list ap;
Expand All @@ -669,4 +686,29 @@ void Fl_Terminal_printf(Fl_Terminal *self, const char *fmt, ...) {
va_end(ap);
}

/////////////////////////////////////////////////////////////////////////////////////////
// Utf8Char class methods.
// So far, only "getters" are implemented. No "setters" or constructors, so no way
// to build a new Utf8 object.

const unsigned char *Fl_Terminal_Utf8Char_text_utf8(Fl_Terminal_Utf8Char *self) {
auto self1 = (Fl_Terminal_Derived::Utf8Char *) self;
LOCK(auto ret = (const unsigned char *)self1->text_utf8());
return ret;
}

/// Get length of bytes in text_utf8: 1 for ASCII, >1 for UTF-8
int Fl_Terminal_Utf8Char_length(Fl_Terminal_Utf8Char *self) {
auto self1 = (Fl_Terminal_Derived::Utf8Char *) self;
LOCK(auto ret = self1->length());
return ret;
}

/// TMP for testing: generate a UTF8Char
Fl_Terminal_Utf8Char * Fl_Terminal_Utf8Char_new_obj(char c) {
// LOCK(auto ret = Fl_Terminal_Utf8Char_text_char(c));
LOCK(auto ret = Fl_Terminal_Derived::Utf8Char::new_obj(c));
return ret;
}

GROUP_DEFINE(Fl_Terminal)

0 comments on commit 9b1ae58

Please sign in to comment.