FLTK-C-1.3.3 for FreeBASIC

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK-C-1.3.3 for FreeBASIC

Post by D.J.Peters »

Knatterton wrote:I hope you are not insulted, when i do changes on your files, Joshy.
On a heat night I will come from behind and kill you :-)

"my files" are primary tests for the C++ wrapper not seen as "tutorial" or "command reference" I know why and how I wrote it.

You are free to publish "working" stuff if it makes any sense for users.

Would be a good idea to use other file names.

The point are if something goes wrong and an fltk-c user runs in to trouble
than I can refer to my "original tests" like "Fl_XYZ01.bas" without any changes of course.

You can add a suffix if you like for example "Fl_Button01_test.bas" or Fl_Roller_example.bas" ...

Happy GUI coding and do a look behind you in the heat of the night.

Joshy
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

D.J.Peters wrote:On a heat night I will come from behind and kill you :-
No luck, i am always sleeping with back to the wall. :-)
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

Again did a lot of little cosmetics. Naturally it was easy to connect the compile command with the cmd-line. Now it is so far it loads it's own code and compiles itself. But you can see it only at the time stamp of the executable.

Code: Select all

' FastLighter.bas
' IDE for FreeBASIC 1.06 and Fltk-c 1.3.3 
' by Knatterton

#ifdef __FB_WIN32__ ' goes for all windows
	var shared fbc_name = @"fbc*.exe"
	var shared fbc_path = @"\FreeBASIC\"
	var shared file_name = @"FastLighter.bas"
	var shared file_path = @"\FreeBASIC\"
#else ' linux or mac
	var shared fbc_name = @"fbc"
	var shared fbc_path = @"/usr/local/bin/"
	var shared file_name = @"FastLighter.bas"
	var shared file_path = @"/home/fujitsu/Projekte/"
#endif

dim shared as ubyte r8=218,g8=243,b8=200
dim shared as string cmd_line
cmd_line = " " & *file_name

#include once "fltk-c.bi"
#include once "fbc_options.bi"

dim as Fl_Window ptr win = Fl_WindowNew(1024,768, "FastLighter")
var edt = Fl_Text_EditorNew(10,40,Fl_WidgetGetW(win)-20,Fl_WidgetGetH(win)-50)
dim shared as Fl_Text_Buffer ptr buf
buf = Fl_Text_BufferNew()
var hd  = Fl_Text_BufferNew()

' menubar
sub NewCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  Fl_Text_BufferSetText(buf,"")
end sub

sub OpenCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
 flFileChooserOkLabel("Open")
 dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*", FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  var file = Fl_File_ChooserGetValue(fc)
  if file then print "pathfile: " & *file
  Fl_Text_BufferLoadFile(buf,file) 
end sub

sub SaveCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  if Fl_Text_BufferSaveFile(buf,file_name) <> 0 then
    print "error"
  end if
end sub

sub SaveAsCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  'flFileChooserOkLabel("Save")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*", FL_FILECHOOSER_SINGLE, "Select a file")
  flFileChooserOkLabel("Save")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  var file = Fl_File_ChooserGetValue(fc)
  if file then print "pathfile: " & *file 
  if Fl_Text_BufferSaveFile(buf,file) <> 0 then
    print "error"
  end if
end sub

sub PrintCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
end sub

sub QuitCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  if flChoice("Do you really want to exit ?","no","yes") then
    Fl_WindowHide Fl_WidgetWindow(self)
  end if
end sub

sub UndoCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
end sub

sub CutCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
end sub

sub CopyCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
end sub

sub PasteCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
end sub

sub DeleteCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
end sub

sub FindCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
end sub

sub ReplaceCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  var hv  = Fl_Help_ViewNew(10,10,620,460)
  Fl_Help_ViewLoad hv,"media/test01.html"
end sub

sub CompileCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
   'A Windows based example but the same idea applies to Linux
	Dim result As Integer
	result = Exec( *fbc_name, cmd_line)
	If result = -1 Then
	    Print "Error running "; fbc_name
	Else
	    Print "Exit code:"; result
	End If
end sub

sub InputCB cdecl (byval self as Fl_Widget ptr)
  print fbc_path & fbc_name
end sub

sub InputButtonCB cdecl (byval button as FL_WIDGET ptr, inputtext as any ptr)
  flFileChooserOkLabel("Take it")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Find Fbc")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP)
  file = Mid(filepath, last + 1, len(filepath))
  fbc_opt(37).value = file
  'Fl_WindowCopyLabel but,file
  Fl_Input_SetValue(inputtext, filepath)
  print filepath '*path
end sub

sub PrefEndButtonCB cdecl (byval button as FL_WIDGET ptr, pref as any ptr)
  Fl_WindowHide pref
end sub

'Dim Shared As Fl_Input Ptr Input_text

sub OptionsCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  fbc_options
end sub

sub PrefCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
	var pref = Fl_WindowNew(440, 100, "Preferences")
	Fl_WindowSetModal(pref)
	var Input_text = Fl_InputNew(120, 12,200, 20, "Path to FBC:")
	Fl_WidgetSetCallback0(Input_text, @InputCB)
	Fl_Input_SetValue(Input_text, *fbc_path & *fbc_name)
	
	var Btn1 = Fl_ButtonNew(330,12,60,22,"Choose")
	Fl_WidgetSetCallbackArg Btn1,@InputButtonCB, Input_text
	
	var Btn2 = Fl_ButtonNew(330,60,60,22,"OK")
	Fl_WidgetSetCallbackArg Btn2,@PrefEndButtonCB, pref
	Fl_WindowShow pref
end sub

sub ColorBackCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  flColorChooser "flColorChooser()",r8,g8,b8, FL_COLORCHOOSER_RGB
  Fl_Background(r8,g8,b8)
  Fl_ReDraw()
end sub

sub ColorForeCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  flColorChooser "flColorChooser()",r8,g8,b8, FL_COLORCHOOSER_RGB
  Fl_Foreground(r8,g8,b8)
  Fl_ReDraw()
end sub

sub GtkCB cdecl (byval self as Fl_Widget ptr, byval userData as any ptr)
  Fl_SetScheme("gtk+") : Fl_ReDraw()
end sub 

sub PlasticCB cdecl (byval self as Fl_Widget ptr, byval userData as any ptr)
  Fl_SetScheme("plastic") : Fl_ReDraw()
end sub

sub GleamCB cdecl (byval self as Fl_Widget ptr, byval userData as any ptr)
  Fl_SetScheme("gleam") : Fl_ReDraw()
end sub 

sub NoneCB cdecl (byval self as Fl_Widget ptr, byval userData as any ptr)
  Fl_SetScheme("none")
  Fl_ReDraw()
end sub 

sub DokuCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  var WinWidth = 800
  var WinHeight = 600
  var win = Fl_Double_WindowNew2(Fl_GetW()/2-WinWidth /2, Fl_GetH()/2-WinHeight/2, _
      WinWidth,WinHeight,"Documentation")                    
  var hv  = Fl_Help_ViewNew(0,0,800,600)
  Fl_Help_ViewLoad hv,"Html/any.html"
  Fl_GroupSetResizable win,hv
  Fl_WindowShow win
end sub

sub AboutEndButtonCB cdecl (byval button as FL_WIDGET ptr, pref as any ptr)
  Fl_WindowHide pref
end sub

sub AboutCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  var pref = Fl_WindowNew(555, 333, "About")
	var fl_boxn = Fl_BoxNew(100,40,350,150, "FastLighter by Knatterton with FreeBASIC 1.06 and Fltk 1.3.3")
	
	var Btn2 = Fl_ButtonNew(230,290,60,22,"OK")
	Fl_WidgetSetCallbackArg Btn2,@AboutEndButtonCB, pref
	Fl_WindowShow pref
  'flMessage("FastLighter by Knatterton")
end sub

Fl_Register_Images() : Fl_File_IconLoadSystemIcons() ' <--- good idea in all programs
Fl_WindowBegin(win)

Fl_Text_DisplaySetLinenumberWidth edt,40 ' 0 = line numbers off
Fl_Text_DisplaySetBuffer edt,buf

if Fl_Text_BufferLoadFile(buf,"FastLighter.bas") <> 0 then
  Fl_Text_BufferSetText(buf,!"print \"type your stuff\"")
end if

Fl_GroupSetResizable win,edt

var mnb = Fl_Menu_BarNew(0,0,1024,30)

' Overwrite default colors
Fl_Background(r8,g8,b8)
Fl_Foreground(230,250,254)
Fl_Menu_SetTextFont(mnb,Fl_TIMES)

Fl_Menu_Add(mnb,"File/New"        , FL_CTRL+asc("n"),     @NewCB)
Fl_Menu_Add(mnb,"File/Open..."    , FL_CTRL+asc("o"),     @OpenCB)
Fl_Menu_Add(mnb,"File/Save"       , FL_CTRL+asc("s"),     @SaveCB)
Fl_Menu_Add(mnb,"File/Save &As...", FL_CTRL+asc("a"),     @SaveAsCB)
Fl_Menu_Add(mnb,"File/Print"      , FL_CTRL+asc("p"),     @PrintCB)
Fl_Menu_Add(mnb,"File/Quit"       , FL_CTRL+asc("q"),     @QuitCB)

Fl_Menu_Add(mnb,"Edit/Undo"       , FL_CTRL+asc("u"),     @UndoCB)
Fl_Menu_Add(mnb,"Edit/Cut"        , FL_CTRL+asc("x"),     @CutCB)
Fl_Menu_Add(mnb,"Edit/Copy"       , FL_CTRL+asc("v"),     @CopyCB)
Fl_Menu_Add(mnb,"Edit/Paste"      , FL_CTRL+asc("x"),     @PasteCB)
Fl_Menu_Add(mnb,"Edit/Delete"     , FL_CTRL+asc("x"),     @DeleteCB)
Fl_Menu_Add(mnb,"Edit/Search"     , FL_CTRL+asc("v"),     @AboutCB)

Fl_Menu_Add(mnb,"Search/Find..."   ,FL_CTRL+asc("x"),     @FindCB)
Fl_Menu_Add(mnb,"Search/Replace...",FL_CTRL+asc("x"),     @ReplaceCB)
Fl_Menu_Add(mnb,"Search/Extended",  FL_CTRL+asc("x"),     @AboutCB)

Fl_Menu_Add(mnb,"Compile/Compile",     FL_CTRL+asc("c"),  @CompileCB)
Fl_Menu_Add(mnb,"Compile/Options",     FL_CTRL+asc("p"),  @OptionsCB)
Fl_Menu_Add(mnb,"Compile/Preferences", FL_CTRL+asc("p"),  @PrefCB)


Fl_Menu_Add(mnb,"View/Gtk+",                    	   ,  @GtkCB)
Fl_Menu_Add(mnb,"View/Plastic",                        ,  @PlasticCB)
Fl_Menu_Add(mnb,"View/Gleam",                          ,  @GleamCB)
Fl_Menu_Add(mnb,"View/None",                           ,  @NoneCB)
Fl_Menu_Add(mnb,"View/Back Color" , FL_CTRL+asc("z")   ,  @ColorBackCB)
Fl_Menu_Add(mnb,"View/Fore Color" , FL_CTRL+asc("z")   ,  @ColorForeCB)

Fl_Menu_Add(mnb,"Help/Documentation"  ,FL_CTRL+asc("d"),  @DokuCB)
Fl_Menu_Add(mnb,"Help/About",,                            @AboutCB)

Fl_Menu_Add3(mnb,"Help/Help/Item 1")
Fl_Menu_Add3(mnb,"Help/Help/Item 2")
Fl_Menu_Add3(mnb,"Help/Help/Item 3")

Fl_WindowShow win
Fl_Run

' end FastLighter.bas

Code: Select all

' fbc_options.bi
' by Knatterton

#include once "vbcompat.bi"
#include once "fltk-c.bi"

type toptions
  as string activ = "0", opt, para, desc, value, ind = "0"
end type

dim shared as toptions fbc_opt(60) 

for i as short = 0 to 60 
  with fbc_opt(i)
    read (.opt)
    read (.para)
    read (.desc)
    read (.value)
  end with
next i

data " @","<argfile>","Read more command line arguments from a file", "<file>", _
" -a","<inputfile>","Treat file as .o/.a input file", "<file>", _
" -arch","arch","Set target architecture (default: 486)", "native", _
" -asm","att|intel","Set asm format (-gen gcc|llvm, x86 or x86_64 only)", "intel", _
" -b","<basfile>","Treat file as .bas input file", "<file>", _
" -c","","Compile only, do not link", "", _
" -C","","Preserve temporary .o files", "", _
" -d","define","Add a global #define", "", _
" -dll","","Same as -dylib", "", _
" -dylib","","Create a DLL (win32) or shared library (*nix/*BSD)", "", _
" -e","","Enable runtime error checking", "", _
" -ex","","-e plus RESUME support", "", _
" -exx","","-ex plus array bounds/null-pointer checking", "", _
" -export","","Export symbols for dynamic linkage", "", _
" -forcelang","force","Override #lang statements in source code", "fb", _
" -fpmode","fast|precise","Select floating-point math accuracy/speed", "fast", _
" -fpu","x87|sse","Set target FPU", "sse", _
" -g","","Add debug info", "", _
" -gen","gas|gcc|llvm","Select code generation backend", "gcc", _
" -help","","Show this help output", "", _
" -i","<incpath>","Add an include file search path", "<path>", _
" -include","<incfile>","Pre-#include a file for each input .bas", "<file>", _
" -l","link","Link in a library", "", _
" -lang","lang","Select FB dialect: fb, deprecated, fblite, qb", "fb", _
" -lib","","Create a static library", "", _
" -m","module","Specify main module (default if not -c: first input .bas)", "", _
" -map","<mapfile>","Save linking map to file", "<file>", _
" -maxerr","maxerr","Only show <n> errors", "0", _
" -mt","","Use thread-safe FB runtime", "", _
" -nodeflibs","","Do not include the default libraries", "", _
" -noerrline","","Do not show source context in error messages", "", _
" -noobjinfo","","Do not read/write compile-time info from/to .o and .a files", "", _
" -o","<namefile>","Set .o (or -pp .bas) file name for prev/next input file", "<file>", _
" -O","optimize","Optimization level (default: 0)", "0", _
" -p","<libpath>","Add a library search path", "<path>", _
" -pic","","Generate position-independent code (non-x86 Unix shared libs)", "", _
" -pp","","Write out preprocessed input file (.pp.bas) only", "", _
" -prefix","<prepath>","Set the compiler prefix path", "<path>", _
" -print","host|target","Display host/target system name", "target", _
" -print fblibdir","fblibdir","fDisplay the compiler's lib/ path", "", _
" -print x","x","Display output binary/library file name (if known)", "", _
" -profile","","Enable function profiling", "", _
" -r","","Write out .asm/.c/.ll (-gen gas/gcc/llvm) only", "", _
" -rr","","Write out the final .asm only", "", _
" -R","","Preserve temporary .asm/.c/.ll/.def files", "", _
" -RR","","Preserve the final .asm file", "", _
" -s","console|gui","Select win32 subsystem", "gui", _
" -showincludes","","Display a tree of file names of #included files", "", _
" -static","","Prefer static libraries over dynamic ones when linking", "", _
" -t","stack","Set .exe stack size in kbytes, default: 1024 (win32/dos)", "1024", _
" -target","target","Set cross-compilation target", "dos", _
" -title","title","Set XBE display title (xbox)", "", _
" -v","","Be verbose", "", _
" -vec","vector","Automatic vectorization level (default: 0)", "0", _
" -version","","Show compiler version	", "", _
" -w","all|pedantic|<n>","Set min warning level: all, pedantic or a value", "all", _
" -Wa","wa","Pass options to 'as'", "", _
" -Wc","wc","Pass options to 'gcc' (-gen gcc) or 'llc' (-gen llvm)", "", _
" -Wl","wl","Pass options to 'ld'", "", _
" -x","<outfile>","Set output executable/library file name", "<file>", _
" -z","setjmp","Use setjmp/longjmp to implement GOSUB", "gosub"

sub load_opts  ' open and read the file
   dim as integer filehandle
   filehandle = freefile
   open "fbc.opt" for input as #filehandle
   for i as short = 0 to 60
       line input #filehandle, fbc_opt(i).activ
       line input #filehandle, fbc_opt(i).value
       line input #filehandle, fbc_opt(i).ind
   next i    
   close #filehandle
end sub

sub save_opts ' open and write the file
   dim as integer filehandle
   filehandle = freefile
   open "fbc.opt" for output as #filehandle
   for i as short = 0 to 60
      print #filehandle, fbc_opt(i).activ
      print #filehandle, fbc_opt(i).value
      print #filehandle, fbc_opt(i).ind
   next i
   close #filehandle
end sub

sub Fl_File_ChooserShowCenter(byval fc as FL_File_Chooser ptr)
  var win = cptr(FL_Double_Window ptr,Fl_WidgetWindow(Fl_File_ChooserNewButton(fc)))
  var scrW=Fl_GetW()          ' get screen width,height
  var scrH=Fl_GetH()
  var winW=Fl_WidgetGetW(win) ' get current win width,height
  var winH=Fl_WidgetGetH(win)
  var newX = scrW/2-winW/2    ' calculate new center position
  var newY = scrH/2-winH/2
  Fl_WidgetPosition(win,newX,newY)
  Fl_Double_WindowShow(win)
  Fl_File_ChooserRescanKeepFilename(fc)
end sub

sub CheckCB cdecl (byval self as FL_WIDGET ptr,byval CheckButton as any ptr)
  var opt = *Fl_WidgetGetLabel(CheckButton)
  for i as short = 0 to 60
	if fbc_opt(i).opt = opt then
	  if fbc_opt(i).activ = "0" then 
	    fbc_opt(i).activ = "1"
	  else
	    fbc_opt(i).activ = "0"
	  end if
	  print *Fl_WidgetGetLabel(CheckButton)
      print fbc_opt(i).activ
	  exit for
	end if
  next i
end sub

' file callbacks
sub ArgFileCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as string path = *Fl_File_ChooserGetDirectory(fc) 
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP) ' 'SEP = "\" for win or "/" for linux, done in fltk-tools.b
  file = Mid(filepath, last + 1, len(filepath))
  ? "pathfile: " & filepath
  ? "file: " & file 
  ? "path: " & path
  fbc_opt(0).value = file
  'Fl_WindowCopyLabel but, ".." & right (file,20)
  Fl_WindowCopyLabel but, left(file,17) & ".." ' display only the beginning on button
end sub

sub InputFileCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP)
  file = Mid(filepath, last + 1, len(filepath))
  fbc_opt(1).value = file
   Fl_WindowCopyLabel but, left(file,17) & ".." ' display only the beginning on button
end sub

sub BasFileCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP)
  file = Mid(filepath, last + 1, len(filepath))
  fbc_opt(4).value = file
   Fl_WindowCopyLabel but, left(file,17) & ".." ' display only the beginning on button
end sub

sub IncFileCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP)
  file = Mid(filepath, last + 1, len(filepath))
  fbc_opt(20).value = file
   Fl_WindowCopyLabel but, left(file,17) & ".." ' display only the beginning on button
end sub

sub MapFileCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP)
  file = Mid(filepath, last + 1, len(filepath))
  fbc_opt(24).value = file
   Fl_WindowCopyLabel but, left(file,17) & ".." ' display only the beginning on button
end sub

sub NameFileCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open")
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP)
  file = Mid(filepath, last + 1, len(filepath))
  fbc_opt(32).value = file
   Fl_WindowCopyLabel but, left(file,17) & ".." ' display only the beginning on button
end sub

sub OutFileCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open") 
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  dim as string file
  dim as long last
  ' get file name out of filepath
  last = InStrRev(filepath, SEP)
  file = Mid(filepath, last + 1, len(filepath))
  fbc_opt(59).value = file
   Fl_WindowCopyLabel but, left(file,17) & ".." ' display only the beginning on button
end sub

' path callbacks
sub IncPathCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open") 
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string path = *Fl_File_ChooserGetDirectory(fc) 
  fbc_opt(20).value = path
  Fl_WindowCopyLabel but, ".." & right(path,16) ' display only the end on button
end sub

sub LibPathCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open") 
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string path = *Fl_File_ChooserGetDirectory(fc) 
  fbc_opt(34).value = path
 Fl_WindowCopyLabel but, ".." & right(path,16) ' display only the end on button
end sub

sub PrePathCB cdecl (byval self as Fl_Widget ptr,byval but as any ptr)
  flFileChooserOkLabel("Open") 
  dim as string result = CurDir
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select a file")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string path = *Fl_File_ChooserGetDirectory(fc) 
  fbc_opt(37).value = path
  Fl_WindowCopyLabel but, ".." & right(path,16) ' display only the end on button
end sub

' choice callbacks
sub ArchChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(2).ind = str(ind)
  fbc_opt(2).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(2).value
end sub

sub AsmChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(3).ind = str(ind)
  fbc_opt(3).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(3).value
end sub

sub FastChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(15).ind = str(ind)
  fbc_opt(15).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(15).value
end sub

sub FpuChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(16).ind = str(ind)
  fbc_opt(16).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(16).value
end sub

sub GenChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(18).ind = str(ind)
  fbc_opt(18).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(18).value
end sub

sub ForceChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(14).ind = str(ind)
  fbc_opt(14).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(14).value
end sub

sub LangChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(23).ind = str(ind)
  fbc_opt(23).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(23).value
end sub

sub PrintChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(38).ind = str(ind)
  fbc_opt(38).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(38).value
end sub

sub GuiChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(46).ind = str(ind)
  fbc_opt(46).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(46).value
end sub

sub WarnChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(55).ind = str(ind)
  fbc_opt(55).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(55).value
end sub

sub SetChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(60).ind = str(ind)
  fbc_opt(60).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(60).value
end sub

sub TargetChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  var ind = Fl_ChoiceGetValue(cho)
  fbc_opt(50).ind = str(ind)
  fbc_opt(50).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? fbc_opt(50).value
end sub

' string input callbacks
sub DefInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(7).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(7).value 
end sub

sub LinkInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(22).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(22).value
end sub

sub ModuleInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(25).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(25).value
end sub

sub TitleInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(51).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(51).value
end sub

sub WaInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(56).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(56).value
end sub

sub WcInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(57).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(57).value
end sub

sub WlInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(58).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(58).value
end sub


' integer input callbacks
sub MaxInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(27).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(27).value
end sub

sub OptInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(33).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(33).value
end sub

sub StackInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(49).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(49).value
end sub

sub VecInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  fbc_opt(53).value = *Fl_Input_GetValue(input_)
  ? fbc_opt(53).value
end sub

' button callbacks
sub CancelButtonCB cdecl (byval button as FL_WIDGET ptr, options as any ptr)
  Fl_WindowHide(options)
end sub

sub OKButtonCB cdecl (byval button as FL_WIDGET ptr, options as any ptr)
  cmd_line = ""
  for i as short = 0 to 60
  with fbc_opt(i)
    if .activ = "1" then   
      cmd_line += .opt
      if .value <> "" then
        cmd_line += " " & .value
      end if  
    end if
  end with
  next i
  cmd_line += " "
  cmd_line += *file_name
  ? cmd_line '& " " & *file_name
  Fl_WindowHide(options)
  save_opts
end sub

' options window
sub fbc_options
	dim as Fl_Window ptr options = Fl_WindowNew(860,640,"Fbc options")
	var cancelbtn = Fl_ButtonNew(Fl_WidgetGetW(options)-180,Fl_WidgetGetH(options)-40,70,24,"Cancel")
	var okbtn = Fl_ButtonNew(Fl_WidgetGetW(options)-90,Fl_WidgetGetH(options)-40,70,24,"OK")
	Fl_WidgetSetCallbackArg cancelbtn, @CancelButtonCB, options
	Fl_WidgetSetCallbackArg okbtn, @OkButtonCB, options
	
	var scr = Fl_ScrollNew(20,20,Fl_WidgetGetW(options)-40,Fl_WidgetGetH(options)-80)
	
	' get the V Scrollbar
	var v = Fl_ScrollScrollbar(scr)
	Fl_WidgetSetAlign v,Fl_ALIGN_BOTTOM_RIGHT ' <-- default
	                       
	dim as Fl_Check_Button ptr cb(60)
	'dim as Fl_Button ptr btn(60)
	
	If fileexists("fbc.opt") then load_opts
	
	' create the lines
	for i as short = 0 to 60
	  with fbc_opt(i)
	   cb(i) = Fl_Check_ButtonNew(24,i*24+24,24,24, .opt)
	   Fl_WidgetSetCallbackArg cb(i),@CheckCB,cb(i)
	   Fl_ButtonSetValue(cb(i),valint(.activ))
	   
	   var fl_boxn = Fl_BoxNew(340,i*24+24,450,24, .desc)
	   Fl_WidgetSetAlign *fl_boxn,Fl_ALIGN_LEFT or Fl_ALIGN_INSIDE
	   
	   select case .para
	   
	     case ""
	       exit select
	       
	    ' case "<file>"
	     '  btn(i) = Fl_ButtonNew(160,i*24+24,140,24,.para)
	     
	     ' file buttons  
	     case "<argfile>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@ArgFileCB,btn
	       Fl_WidgetSetLabel(btn, .value)
	       
	     case "<inputfile>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@InputFileCB,btn
	       Fl_WidgetSetLabel(btn, .value)
	     
	     case "<basfile>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@BasFileCB,btn
	       Fl_WidgetSetLabel(btn, .value)
	       
	     case "<incfile>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@IncFileCB,btn
	       Fl_WidgetSetLabel(btn, .value)  
	       
	     case "<mapfile>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@MapFileCB,btn
	       Fl_WidgetSetLabel(btn, .value)
	       
	     case "<namefile>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@NameFileCB,btn
	       Fl_WidgetSetLabel(btn, .value)
	       
	     case "<outfile>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@OutFileCB,btn
	       Fl_WidgetSetLabel(btn, .value)
	       
	      ' path buttons 
	     case "<incpath>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@IncPathCB,btn
	      ' Fl_WidgetSetLabel(btn, .value)
	      ' dim as string path = ".." & right(.value,16)
	      ' dim as string path = right(.value,16)
	      ' Fl_WidgetSetLabel(btn, path) ' display only the end on button
	       Fl_WidgetSetLabel(btn, "<path>") ' display only <path> on button
	       
	     case "<libpath>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@LibPathCB,btn
	      ' Fl_WidgetSetLabel(btn, .value)
	     '  Fl_WidgetSetLabel(btn, ".." & right(.value,16)) ' display only the end on button
	      ' dim as string path = ".." & right(.value,16)
	      ' Fl_WidgetSetLabel(btn, path) ' display only the end on button
	       Fl_WidgetSetLabel(btn, "<path>") ' display only <path> on button
	       
	     case "<prepath>"
	       var btn = Fl_ButtonNew(160,i*24+24,140,24,.para)
	       Fl_WidgetSetCallbackArg btn,@PrePathCB,btn
	       'Fl_WidgetSetLabel(btn, .value)
	      ' dim as string path = ".." & right(.value,16)
	      ' Fl_WidgetSetLabel(btn, path) ' display only the end on button
	       Fl_WidgetSetLabel(btn, "<path>") ' display only <path> on button
	   
	     ' choice widgets
	     case "arch"
	       var arch = Fl_ChoiceNew(160,i*24+24,140,24,"")
		   Fl_Menu_Add3(arch,"native")
		   Fl_Menu_Add3(arch,"32")
	       Fl_Menu_Add3(arch,"64")
		   Fl_Menu_Add3(arch,"386")
		   Fl_Menu_Add3(arch,"486")
		   Fl_Menu_Add3(arch,"586")
		   Fl_Menu_Add3(arch,"686")
		   Fl_Menu_Add3(arch,"athlon")
		   Fl_Menu_Add3(arch,"athlon-xp")
		   Fl_Menu_Add3(arch,"athlon-fx")
		   Fl_Menu_Add3(arch,"k8-")
		   Fl_Menu_Add3(arch,"pentium-mmx")
		   Fl_Menu_Add3(arch,"pentium2")
		   Fl_Menu_Add3(arch,"pentium3")
		   Fl_Menu_Add3(arch,"pentium4")
		   Fl_Menu_Add3(arch,"pentium4-sse3")
		   Fl_Menu_Add3(arch,"x86_64")
		   Fl_Menu_Add3(arch,"x86-64")
		   Fl_Menu_Add3(arch,"amd64")
		   Fl_Menu_Add3(arch,"armv6")
		   Fl_Menu_Add3(arch,"armv7-a")
		   Fl_Menu_Add3(arch,"aarch64")
		   Fl_ChoiceSetValue(arch,valint(.ind))
		   Fl_WidgetSetCallbackArg arch,@ArchChoiceCB,arch
		   
		 case "lang"
	       var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
	       Fl_Menu_Add3(cho,"fb")
		   Fl_Menu_Add3(cho,"deprecated")
		   Fl_Menu_Add3(cho,"fblite")
		   Fl_Menu_Add3(cho,"qb")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@LangChoiceCB,cho
		   
		 case "force"
	       var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
	       Fl_Menu_Add3(cho,"fb")
		   Fl_Menu_Add3(cho,"deprecated")
		   Fl_Menu_Add3(cho,"fblite")
		   Fl_Menu_Add3(cho,"qb")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@ForceChoiceCB,cho
	
	     case "att|intel"
	       var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
		   Fl_Menu_Add3(cho,"intel")
		    Fl_Menu_Add3(cho,"att")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@AsmChoiceCB,cho
			
		 case "fast|precise"
		   var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
		   Fl_Menu_Add3(cho,"fast")
		   Fl_Menu_Add3(cho,"precise")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@FastChoiceCB,cho
		
		 case "x87|sse"
		   var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
		   Fl_Menu_Add3(cho,"sse")
	       Fl_Menu_Add3(cho,"x87")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@FpuChoiceCB,cho
	
	     case "gas|gcc|llvm"
	       var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
	       Fl_Menu_Add3(cho,"gas")
		   Fl_Menu_Add3(cho,"gcc")
		   Fl_Menu_Add3(cho,"llmv")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@GenChoiceCB,cho
	     
	     case "host|target"
	       var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
	       Fl_Menu_Add3(cho,"host")
		   Fl_Menu_Add3(cho,"target")
		  ' Fl_Menu_Add3(cho,"fblibdir") ' existing twice 
		  ' Fl_Menu_Add3(cho,"x")        ' existing twice
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@PrintChoiceCB,cho
	     
	     case "console|gui"
	       var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
	       Fl_Menu_Add3(cho,"gui")
	       Fl_Menu_Add3(cho,"console")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@GuiChoiceCB,cho
	     
		 case "all|pedantic|<n>"
		   var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
	       Fl_Menu_Add3(cho,"all")
	       Fl_Menu_Add3(cho,"none")
		   Fl_Menu_Add3(cho,"pedantic")
		   Fl_Menu_Add3(cho,"param")
		   Fl_Menu_Add3(cho,"Escape")
		   Fl_Menu_Add3(cho,"Next")
		   Fl_Menu_Add3(cho,"funcptr")
		   Fl_Menu_Add3(cho,"constness")
		   Fl_Menu_Add3(cho,"-1")
		   Fl_Menu_Add3(cho,"0")
		   Fl_Menu_Add3(cho,"1")
		   Fl_Menu_Add3(cho,"2")
		   Fl_Menu_Add3(cho,"3")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@WarnChoiceCB,cho
		   
		 case "setjmp"
		   var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
		   Fl_Menu_Add3(cho,"gosub")
		   Fl_Menu_Add3(cho,"setjmp")
		   Fl_ChoiceSetValue(cho,valint(.ind))
		   Fl_WidgetSetCallbackArg cho,@SetChoiceCB,cho
		   
		 case "target"
		   var cho = Fl_ChoiceNew(160,i*24+24,140,24,"")
		   Fl_Menu_Add3(cho,"dos")
		   Fl_Menu_Add3(cho,"win32")
		   Fl_Menu_Add3(cho,"win64")
		   Fl_Menu_Add3(cho,"xbox")
	      '<os>-<arch>
	      '<os> can be one of:      
		   Fl_Menu_Add3(cho,"linux-x86")
		   Fl_Menu_Add3(cho,"linux-x86_64")
		   Fl_Menu_Add3(cho,"linux-arm")
		   Fl_Menu_Add3(cho,"linux-aarch64")
		   Fl_Menu_Add3(cho,"cygwin-x86")
		   Fl_Menu_Add3(cho,"cygwin-x86_64")
		   Fl_Menu_Add3(cho,"cygwin-arm")
		   Fl_Menu_Add3(cho,"cygwin-aarch64")	   
		   Fl_Menu_Add3(cho,"darwin-x86")
		   Fl_Menu_Add3(cho,"darwin-x86_64")
		   Fl_Menu_Add3(cho,"darwin-arm")
		   Fl_Menu_Add3(cho,"darwin-aarch64")
		   Fl_Menu_Add3(cho,"freebsd-x86")
		   Fl_Menu_Add3(cho,"freebsd-x86_64")
		   Fl_Menu_Add3(cho,"freebsd-arm")
		   Fl_Menu_Add3(cho,"freebsd-aarch64")
		   Fl_Menu_Add3(cho,"netbsd-x86")
		   Fl_Menu_Add3(cho,"netbsd-x86_64")
		   Fl_Menu_Add3(cho,"netbsd-arm")
		   Fl_Menu_Add3(cho,"netbsd-aarch64")
		   Fl_Menu_Add3(cho,"openbsd-x86")
		   Fl_Menu_Add3(cho,"openbsd-x86_64")
		   Fl_Menu_Add3(cho,"openbsd-arm")
		   Fl_Menu_Add3(cho,"openbsd-aarch64")
		   Fl_ChoiceSetValue(cho,valint(.ind))
	       Fl_WidgetSetCallbackArg cho,@TargetChoiceCB,cho
		   
		 ' string input widgets 
		  case "define"
	       var inp1 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp1, .value)
	       Fl_WidgetSetCallbackArg inp1,@DefInputCB,inp1
	           
	     case "link"
	       var inp1 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp1, .value)
	       Fl_WidgetSetCallbackArg inp1,@LinkInputCB,inp1
	       
	     case "module"
	        var inp1 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp1, .value)
	       Fl_WidgetSetCallbackArg inp1,@ModuleInputCB,inp1
	         
	     case "title"
	       var inp1 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp1, .value)
	       Fl_WidgetSetCallbackArg inp1,@TitleInputCB,inp1
	       
	     case "wa"
	       var inp1 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp1, .value)
	       Fl_WidgetSetCallbackArg inp1,@WaInputCB,inp1
	       
	     case "wc"
	       var inp1 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp1, .value)
	       Fl_WidgetSetCallbackArg inp1,@WcInputCB,inp1
	       
	     case "wl"
	       var inp1 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp1, .value)
	       Fl_WidgetSetCallbackArg inp1,@WlInputCB,inp1
	       
		   
		 ' int input widgets
	     case "maxerr"
	       var inp2 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp2, .value)
	       Fl_WidgetSetCallbackArg inp2,@MaxInputCB,inp2
	       
	     case "optimize"
	       var inp2 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp2, .value)
	       Fl_WidgetSetCallbackArg inp2,@OptInputCB,inp2
	       
	     case "stack"
	       var inp2 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp2, .value)
	       Fl_WidgetSetCallbackArg inp2,@StackInputCB,inp2  
	       
	     case "vector"
	       var inp2 = Fl_InputNew(160,i*24+24,140,24,"")
	       Fl_Input_SetValue(inp2, .value)
	       Fl_WidgetSetCallbackArg inp2,@VecInputCB,inp2  
		
	     case else
	      ' btn(i) = Fl_ButtonNew(160,i*24+24,140,24,.para)
	   end select
	    ? i & " Val: " & .value
	  end with
	 
	next
	
	Fl_ScrollScrollTo scr, 0,0
	Fl_GroupSetResizable options,scr
	Fl_WindowShow options
end sub

'fbc_options

'Fl_Run
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: FLTK-C-1.3.3 for FreeBASIC

Post by bcohio2001 »

Run into a little snag in my large project.
C:\FreeBASIC-1.06.0-win64\fbc -s console -exx -w pendantic "FbTemp.bas"
FbTemp.c:1102:35: error: expected identifier or '(' before numeric constant
struct $21FL_RADIO_ROUND_BUTTON* WIN32;
^
FbTemp.c:14:47: error: size of array '__$fb_structsizecheck' is negative
#define __FB_STATIC_ASSERT( expr ) extern int __$fb_structsizecheck[(expr) ? 1 : -1]
^
FbTemp.c:1121:1: note: in expansion of macro '__FB_STATIC_ASSERT'
__FB_STATIC_ASSERT( sizeof( struct $9CONFIGDLG ) == 152 );
^

Make done
Here is the probable "offending" code.

Code: Select all

Type ConfigDlg
	As Fl_Window Ptr Win
	As Fl_Radio_Round_Button Ptr Win32, Linux, Unix, Dos, Cygwin, Darwin, Xbox, OpenBSD, NetBSD, FreeBSD, PCOS
	As Fl_Check_Button Ptr LangQB, Unicode, Bit64, Arm', MakeDefault
	As Fl_Button Ptr Setme
	As Fl_Radio_Round_Button Ptr PlatSet 'holds which radio is set
	As Boolean CanExit 'exit sub flag
End Type

Declare Sub DoConfig(ByRef P As ULong, ByRef C As UShort) 'Config dlg
Declare Sub SetConfig Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr) 'Set button pushed
Declare Sub PlatSel Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr)

Code: Select all

/'This file is part of FB Include Digger.

   FB Include Digger is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   FB Include Digger is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with FB Include Digger.  If not, see <https://www.gnu.org/licenses/>.

   Copyright 2014, 2016-2019 Brian Smith
'/

Sub DoConfig(ByRef P As ULong, ByRef C As UShort)
	Dim As ConfigDlg Dlg
	'
	Dlg.Win = Fl_WindowNew(216, 123, "Configuration")
	Dim As Fl_Group Ptr Group = Fl_GroupNew(5,2,135,100,"") 'platform
	'
	'Platform radios
	Fl_GroupBegin Group
	Dlg.Win32 = Fl_Radio_Round_ButtonNew(6,3,63,15,"Win32")
	Fl_WidgetSetCallbackArg Dlg.Win32, @PlatSel, @Dlg
	Dlg.Linux = Fl_Radio_Round_ButtonNew(6,18,63,15,"Linux")
	Fl_WidgetSetCallbackArg Dlg.Linux, @PlatSel, @Dlg
	Dlg.Unix = Fl_Radio_Round_ButtonNew(69,3,63,15,"Unix")
	Fl_WidgetSetCallbackArg Dlg.Unix, @PlatSel, @Dlg
	Dlg.Dos = Fl_Radio_Round_ButtonNew(6,33,63,15,"Dos")
	Fl_WidgetSetCallbackArg Dlg.Dos, @PlatSel, @Dlg
	Dlg.Cygwin = Fl_Radio_Round_ButtonNew(69,18,63,15,"CYGWIN")
	Fl_WidgetSetCallbackArg Dlg.Cygwin, @PlatSel, @Dlg
	Dlg.Darwin = Fl_Radio_Round_ButtonNew(6,48,63,15,"Darwin")
	Fl_WidgetSetCallbackArg Dlg.Darwin, @PlatSel, @Dlg
	Dlg.Xbox = Fl_Radio_Round_ButtonNew(6,63,63,15,"XBox")
	Fl_WidgetSetCallbackArg Dlg.Xbox, @PlatSel, @Dlg
	Dlg.OpenBSD = Fl_Radio_Round_ButtonNew(69,63,63,15,"OpenBSD")
	Fl_WidgetSetCallbackArg Dlg.OpenBSD, @PlatSel, @Dlg
	Dlg.NetBSD = Fl_Radio_Round_ButtonNew(69,78,63,15,"NetBSD")
	Fl_WidgetSetCallbackArg Dlg.NetBSD, @PlatSel, @Dlg
	Dlg.FreeBSD = Fl_Radio_Round_ButtonNew(69,48,63,15,"FreeBSD")
	Fl_WidgetSetCallbackArg Dlg.FreeBSD, @PlatSel, @Dlg
	Dlg.PCOS = Fl_Radio_Round_ButtonNew(6,78,63,15,"PCOS")
	Fl_WidgetSetCallbackArg Dlg.PCOS, @PlatSel, @Dlg
	Fl_GroupEnd Group
	'
	Dlg.LangQB = Fl_Check_ButtonNew(147,24,60,15,"Lang QB")
	Dlg.Unicode = Fl_Check_ButtonNew(147,9,60,15,"Unicode")
	Dlg.Bit64 = Fl_Check_ButtonNew(147,48,60,15,"64 bit")
	Dlg.Arm = Fl_Check_ButtonNew(147,60,60,15,"ARM")
	'BigEnd = Fl_Check_ButtonNew(147,72,60,15,"BIGENDIAN")
	'Dlg.MakeDefault = Fl_Check_ButtonNew(45,105,69,12,"Default settings")
	'
	Dlg.Setme = Fl_ButtonNew(132,105,57,15,"Set")
	Fl_WidgetSetCallbackArg(Dlg.Setme, @SetConfig, @Dlg)
	Fl_WindowEnd Dlg.Win
	Fl_GroupSetResizable Dlg.Win, Dlg.Win
	'
	If P > 0 Then
		'Platform sent ... set radio
		If (P And FBInc_Plat_Win32) Or (P And FBInc_Plat_Win64) Then
			Fl_ButtonSetOnly(Dlg.Win32)
			Dlg.PlatSet = Dlg.Win32
		EndIf
		If (P And (FBInc_Plat_Linux Or FBInc_Plat_Linux64 Or FBInc_Plat_Linux_ARM Or FBInc_Plat_Linux_ARM64)) Then
			Fl_ButtonSetOnly(Dlg.Linux)
			Dlg.PlatSet = Dlg.Linux
		EndIf
		If (P And FBInc_Plat_Dos) Then
			Fl_ButtonSetOnly(Dlg.Dos) 'only 32 bit
			Dlg.PlatSet = Dlg.Dos
		EndIf
		If (P And FBInc_Plat_CYGWIN) Or (P And FBInc_Plat_CYGWIN64) Then
			Fl_ButtonSetOnly(Dlg.Cygwin)
			Dlg.PlatSet = Dlg.Cygwin
		EndIf
		If (P And FBInc_Plat_UNIX) Or (P And FBInc_Plat_UNIX64) Then
			Fl_ButtonSetOnly(Dlg.Unix)
			Dlg.PlatSet = Dlg.Unix
		EndIf
		If (P And FBInc_Plat_DARWIN) Or (P And FBInc_Plat_DARWIN64) Then
			Fl_ButtonSetOnly(Dlg.Darwin)
			Dlg.PlatSet = Dlg.Darwin
		EndIf
		If (P And (FBInc_Plat_FREEBSD Or FBInc_Plat_FREEBSD_ARM Or FBInc_Plat_FREEBSD64 Or FBInc_Plat_FREEBSD_ARM64)) Then
			Fl_ButtonSetOnly(Dlg.FreeBSD)
			Dlg.PlatSet = Dlg.FreeBSD
		EndIf
		If (P And (FBInc_Plat_OPENBSD Or FBInc_Plat_OPENBSD_ARM Or FBInc_Plat_OPENBSD64 Or FBInc_Plat_OPENBSD_ARM64)) Then
			Fl_ButtonSetOnly(Dlg.OpenBSD)
			Dlg.PlatSet = Dlg.OpenBSD
		EndIf
		If (P And (FBInc_Plat_NETBSD Or FBInc_Plat_NETBSD_ARM Or FBInc_Plat_NETBSD64 Or FBInc_Plat_NETBSD_ARM64)) Then
			Fl_ButtonSetOnly(Dlg.NetBSD)
			Dlg.PlatSet = Dlg.NetBSD
		EndIf
		If (P And (FBInc_Plat_PCOS Or FBInc_Plat_PCOS64)) Then
			Fl_ButtonSetOnly(Dlg.PCOS)
			Dlg.PlatSet = Dlg.PCOS
		EndIf
		If (P And (FBInc_Plat_XBOX Or FBInc_Plat_XBOX64)) Then
			Fl_ButtonSetOnly(Dlg.Xbox) 'original had this disabled
			Dlg.PlatSet = Dlg.Xbox
		EndIf
		'check boxes
		If (C And FBInc_Unicode) Then Fl_ButtonSetOnly(Dlg.Unicode)
		If (C And FBInc_Lang_QB) Then Fl_ButtonSetOnly(Dlg.LangQB)
		'64 bit
		If (P And FBInc_Plat_64Bit) Then Fl_ButtonSetOnly(Dlg.Bit64)
		'ARM?
		If (P And FBInc_Plat_32Arm) Or (P And FBInc_Plat_64Arm) Then Fl_ButtonSetOnly(Dlg.Arm)
	Else
		Fl_WidgetDeactivate(Dlg.Setme)
	EndIf
	'
	Fl_WindowShow Dlg.Win
	'
	'sit here and wait for set button click
	While Dlg.CanExit = FALSE
		Sleep 10
	Wend
	'
	Select Case Dlg.PlatSet
		Case Dlg.Win32
			P = FBInc_Plat_Win32
		Case Dlg.Linux
			P = FBInc_Plat_Linux
			If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = FBInc_Plat_Linux_ARM
		Case Dlg.Unix
			P = FBInc_Plat_UNIX
		Case Dlg.Dos
			P = FBInc_Plat_Dos
		Case Dlg.Cygwin
			P = FBInc_Plat_CYGWIN
		Case Dlg.Darwin
			P = FBInc_Plat_DARWIN
		Case Dlg.FreeBSD
			P = FBInc_Plat_FREEBSD
			If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = FBInc_Plat_FREEBSD_ARM
		Case Dlg.OpenBSD
			P = FBInc_Plat_OPENBSD
			If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = FBInc_Plat_OPENBSD_ARM
		Case Dlg.NetBSD
			P = FBInc_Plat_NETBSD
			If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = FBInc_Plat_NETBSD_ARM
		Case Dlg.PCOS
			P = FBInc_Plat_PCOS
		Case Dlg.Xbox
			P = FBInc_Plat_XBOX
		Case Else
			'None selected ..... Should not happen .....
	End Select
	'64 bit
	If P <> FBInc_Plat_Dos Then
		If Fl_ButtonGetValue(Dlg.Bit64) <> 0 Then P Shl= 16
	EndIf
	'
	'C - Config
	'lang
	If Fl_ButtonGetValue(Dlg.LangQB) <> 0 Then
		C = FBInc_Lang_Mask 'both fb and qb
	Else
		C = FBInc_Lang_FB
	EndIf
	'UNICODE/ANSI
	If Fl_ButtonGetValue(Dlg.Unicode) <> 0 Then
		C Or= FBInc_Unicode
	Else
		C Or= FBInc_ANSI
	EndIf
	Fl_WindowHide(Dlg.Win) 'close dlg
End Sub

Sub SetConfig Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr)
	'user clicked "Set" button
	Dim As ConfigDlg Ptr C = Cast(ConfigDlg Ptr, userdata)
	C->CanExit = TRUE
End Sub

Sub PlatSel Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr)
	Dim As ConfigDlg Ptr C = Cast(ConfigDlg Ptr, userdata)
	C->PlatSet = Cast(Fl_Radio_Round_Button Ptr, self)
	Fl_WidgetActivate(C->Setme)
End Sub
I do not believe that it is my coding or else I would have gotten a fbc error.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK-C-1.3.3 for FreeBASIC

Post by D.J.Peters »

Of course I can't compile your code to many stuff are missed !

But I'm 99% sure the error message comes from the -gen gcc C code emitter with other words no problem with fbc -gen gas (32-bit) should work.

Looks like It's an FreeBASIC thing not fltk-c it self.

Joshy

edit: may be I'm right !
I replaced all missing values with numbers and fbc -gen gas test.bas all are OK but fbc64.exe (-gen gcc) same error message you posted !

Code: Select all

#include once "fltk-c.bi"
/'This file is part of FB Include Digger.

   FB Include Digger is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   FB Include Digger is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with FB Include Digger.  If not, see <https://www.gnu.org/licenses/>.

   Copyright 2014, 2016-2019 Brian Smith
'/
Type ConfigDlg
   As Fl_Window Ptr Win
   As Fl_Radio_Round_Button Ptr Win32, Linux, Unix, Dos, Cygwin, Darwin, Xbox, OpenBSD, NetBSD, FreeBSD, PCOS
   As Fl_Check_Button Ptr LangQB, Unicode, Bit64, Arm', MakeDefault
   As Fl_Button Ptr Setme
   As Fl_Radio_Round_Button Ptr PlatSet 'holds which radio is set
   As Boolean CanExit 'exit sub flag
End Type

Declare Sub DoConfig(ByRef P As ULong, ByRef C As UShort) 'Config dlg
Declare Sub SetConfig Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr) 'Set button pushed
Declare Sub PlatSel Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr)

Sub DoConfig(ByRef P As ULong, ByRef C As UShort)
   Dim As ConfigDlg Dlg
   '
   Dlg.Win = Fl_WindowNew(216, 123, "Configuration")
   Dim As Fl_Group Ptr Group = Fl_GroupNew(5,2,135,100,"") 'platform
   '
   'Platform radios
   Fl_GroupBegin Group
   Dlg.Win32 = Fl_Radio_Round_ButtonNew(6,3,63,15,"Win32")
   Fl_WidgetSetCallbackArg Dlg.Win32, @PlatSel, @Dlg
   Dlg.Linux = Fl_Radio_Round_ButtonNew(6,18,63,15,"Linux")
   Fl_WidgetSetCallbackArg Dlg.Linux, @PlatSel, @Dlg
   Dlg.Unix = Fl_Radio_Round_ButtonNew(69,3,63,15,"Unix")
   Fl_WidgetSetCallbackArg Dlg.Unix, @PlatSel, @Dlg
   Dlg.Dos = Fl_Radio_Round_ButtonNew(6,33,63,15,"Dos")
   Fl_WidgetSetCallbackArg Dlg.Dos, @PlatSel, @Dlg
   Dlg.Cygwin = Fl_Radio_Round_ButtonNew(69,18,63,15,"CYGWIN")
   Fl_WidgetSetCallbackArg Dlg.Cygwin, @PlatSel, @Dlg
   Dlg.Darwin = Fl_Radio_Round_ButtonNew(6,48,63,15,"Darwin")
   Fl_WidgetSetCallbackArg Dlg.Darwin, @PlatSel, @Dlg
   Dlg.Xbox = Fl_Radio_Round_ButtonNew(6,63,63,15,"XBox")
   Fl_WidgetSetCallbackArg Dlg.Xbox, @PlatSel, @Dlg
   Dlg.OpenBSD = Fl_Radio_Round_ButtonNew(69,63,63,15,"OpenBSD")
   Fl_WidgetSetCallbackArg Dlg.OpenBSD, @PlatSel, @Dlg
   Dlg.NetBSD = Fl_Radio_Round_ButtonNew(69,78,63,15,"NetBSD")
   Fl_WidgetSetCallbackArg Dlg.NetBSD, @PlatSel, @Dlg
   Dlg.FreeBSD = Fl_Radio_Round_ButtonNew(69,48,63,15,"FreeBSD")
   Fl_WidgetSetCallbackArg Dlg.FreeBSD, @PlatSel, @Dlg
   Dlg.PCOS = Fl_Radio_Round_ButtonNew(6,78,63,15,"PCOS")
   Fl_WidgetSetCallbackArg Dlg.PCOS, @PlatSel, @Dlg
   Fl_GroupEnd Group
   '
   Dlg.LangQB = Fl_Check_ButtonNew(147,24,60,15,"Lang QB")
   Dlg.Unicode = Fl_Check_ButtonNew(147,9,60,15,"Unicode")
   Dlg.Bit64 = Fl_Check_ButtonNew(147,48,60,15,"64 bit")
   Dlg.Arm = Fl_Check_ButtonNew(147,60,60,15,"ARM")
   'BigEnd = Fl_Check_ButtonNew(147,72,60,15,"BIGENDIAN")
   'Dlg.MakeDefault = Fl_Check_ButtonNew(45,105,69,12,"Default settings")
   '
   Dlg.Setme = Fl_ButtonNew(132,105,57,15,"Set")
   Fl_WidgetSetCallbackArg(Dlg.Setme, @SetConfig, @Dlg)
   Fl_WindowEnd Dlg.Win
   Fl_GroupSetResizable Dlg.Win, Dlg.Win
   '
   If P > 0 Then
      'Platform sent ... set radio
      If (P And 1) Or (P And 2) Then
         Fl_ButtonSetOnly(Dlg.Win32)
         Dlg.PlatSet = Dlg.Win32
      EndIf
      If (P And (1 Or 2 Or 3 Or 4)) Then
         Fl_ButtonSetOnly(Dlg.Linux)
         Dlg.PlatSet = Dlg.Linux
      EndIf
      If (P And 1) Then
         Fl_ButtonSetOnly(Dlg.Dos) 'only 32 bit
         Dlg.PlatSet = Dlg.Dos
      EndIf
      If (P And 1) Or (P And 3) Then
         Fl_ButtonSetOnly(Dlg.Cygwin)
         Dlg.PlatSet = Dlg.Cygwin
      EndIf
      If (P And 1) Or (P And 3) Then
         Fl_ButtonSetOnly(Dlg.Unix)
         Dlg.PlatSet = Dlg.Unix
      EndIf
      If (P And 1) Or (P And 3) Then
         Fl_ButtonSetOnly(Dlg.Darwin)
         Dlg.PlatSet = Dlg.Darwin
      EndIf
      If (P And (1 Or 3 Or 1 Or 3)) Then
         Fl_ButtonSetOnly(Dlg.FreeBSD)
         Dlg.PlatSet = Dlg.FreeBSD
      EndIf
      If (P And (1 Or 3 Or 1 Or 3)) Then
         Fl_ButtonSetOnly(Dlg.OpenBSD)
         Dlg.PlatSet = Dlg.OpenBSD
      EndIf
      If (P And (3 Or 3 Or 1 Or 3)) Then
         Fl_ButtonSetOnly(Dlg.NetBSD)
         Dlg.PlatSet = Dlg.NetBSD
      EndIf
      If (P And (3 Or 3)) Then
         Fl_ButtonSetOnly(Dlg.PCOS)
         Dlg.PlatSet = Dlg.PCOS
      EndIf
      If (P And (3 Or 1)) Then
         Fl_ButtonSetOnly(Dlg.Xbox) 'original had this disabled
         Dlg.PlatSet = Dlg.Xbox
      EndIf
      'check boxes
      If (C And 1) Then Fl_ButtonSetOnly(Dlg.Unicode)
      If (C And 1) Then Fl_ButtonSetOnly(Dlg.LangQB)
      '64 bit
      If (P And 1) Then Fl_ButtonSetOnly(Dlg.Bit64)
      'ARM?
      If (P And 3) Or (P And 1) Then Fl_ButtonSetOnly(Dlg.Arm)
   Else
      Fl_WidgetDeactivate(Dlg.Setme)
   EndIf
   '
   Fl_WindowShow Dlg.Win
   '
   'sit here and wait for set button click
   While Dlg.CanExit = FALSE
      Sleep 10
   Wend
   '
   Select Case Dlg.PlatSet
      Case Dlg.Win32
         P = 1
      Case Dlg.Linux
         P = 3
         If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = 3
      Case Dlg.Unix
         P = 1
      Case Dlg.Dos
         P = 3
      Case Dlg.Cygwin
         P = 1
      Case Dlg.Darwin
         P = 3
      Case Dlg.FreeBSD
         P = 1
         If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = 1
      Case Dlg.OpenBSD
         P = 3
         If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = 3
      Case Dlg.NetBSD
         P = 1
         If Fl_ButtonGetValue(Dlg.Arm) <> 0 Then P = 1
      Case Dlg.PCOS
         P = 3
      Case Dlg.Xbox
         P = 1
      Case Else
         'None selected ..... Should not happen .....
   End Select
   '64 bit
   If P <> 1 Then
      If Fl_ButtonGetValue(Dlg.Bit64) <> 0 Then P Shl= 16
   EndIf
   '
   'C - Config
   'lang
   If Fl_ButtonGetValue(Dlg.LangQB) <> 0 Then
      C = 3 'both fb and qb
   Else
      C = 1
   EndIf
   'UNICODE/ANSI
   If Fl_ButtonGetValue(Dlg.Unicode) <> 0 Then
      C Or= 1
   Else
      C Or= 3
   EndIf
   Fl_WindowHide(Dlg.Win) 'close dlg
End Sub

Sub SetConfig Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr)
   'user clicked "Set" button
   Dim As ConfigDlg Ptr C = Cast(ConfigDlg Ptr, userdata)
   C->CanExit = TRUE
End Sub

Sub PlatSel Cdecl (ByVal self As Fl_Widget Ptr, ByVal userdata As Any Ptr)
   Dim As ConfigDlg Ptr C = Cast(ConfigDlg Ptr, userdata)
   C->PlatSet = Cast(Fl_Radio_Round_Button Ptr, self)
   Fl_WidgetActivate(C->Setme)
End Sub
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK-C-1.3.3 for FreeBASIC

Post by D.J.Peters »

@bcohio2001

the source of trouble are "WIN32" (are a kind of defined word):
Type ConfigDlg
As Fl_Window Ptr Win
As Fl_Radio_Round_Button Ptr Win32 ' <---
...
end type

I renamed Win32 in pWin32 :-)

Joshy
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

D.J.Peters wrote: the source of trouble are "WIN32" (are a kind of defined word):
Funny, had a little adventure to find the file for syntax highlighting in geany. Added "win32" and "boolean".

it is in Mint at:

/usr/share/geany/filedefs/filetypes.freebasic

Code: Select all

# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
default=default
comment=comment_line
commentblock=comment
docline=comment_line_doc
docblock=comment_doc
dockeyword=comment_doc_keyword
number=number_1
word=keyword_1
string=string_1
preprocessor=preprocessor
operator=operator
identifier=identifier_1
date=number_2
stringeol=string_eol
word2=keyword_2
word3=keyword_3
word4=keyword_4
constant=identifier_2
asm=type
label=label
error=error
hexnumber=number_1
binnumber=number_1

[keywords]
# all items must be in one line
keywords=abs access acos alias allocate alpha and andalso any append as asc asin asm assert assertwarn atan2 atn base beep bin binary bit bitreset bitset bload boolean bsave byref byte byval call callocate case cast cbool cbyte cdbl cdecl chain chdir chr cint circle class clear clng clngint close cls color com command common condbroadcast condcreate conddestroy condsignal condwait cons const constructor continue cos cptr cshort csign csng csrlin cubyte cuint culng culngint cunsg curdir cushort custom cvd cvi cvl cvlongint cvs cvshort data date dateadd datediff datepart dateserial datevalue day deallocate declare defbyte defdbl defint deflng deflngint defshort defsng defstr defubyte defuint defulngint defushort delete destructor dim dir do double draw dylibfree dylibload dylibsymbol dynamic else elseif encoding end endif enum environ eof eqv erase erfn erl ermn err error escape exec exepath exit exp explicit export extends extern false fboolean field fileattr filecopy filedatetime fileexists filelen fix flip for format frac fre freefile function get getjoystick getkey getmouse gosub goto hex hibyte hiword hour if iif imageconvertrow imagecreate imagedestroy imp import inkey inp input input$ instr instrrev int integer interface is isdate kill lbound lcase left len let lib line lobyte loc local locate lock lof log long longint loop loword lpos lprint lpt lset ltrim mid minute mkd mkdir mki mkl mklongint mks mkshort mod month monthname multikey mutexcreate mutexdestroy mutexlock mutexunlock name namespace new next nokeyword not now object oct offsetof on once open operator option or orelse out output overload paint palette pascal pcopy peek pipe pmap point pointer poke pos preserve preset print private procptr property protected pset ptr public put random randomize read reallocate redim rem reset restore resume return rgb rgba right rmdir rnd rset rtrim run sadd scope screen screencontrol screencopy screenevent screenglproc screeninfo screenlist screenlock screenptr screenres screenset screensync screenunlock scrn second seek select setdate setenviron setmouse settime sgn shared shell shl short shr sin single sizeof sleep space spc sqr static stdcall step stop str string strptr sub swap system tab tan then this threadcreate threadwait time timer timeserial timevalue to trans trim true type ubound ubyte ucase uinteger ulong ulongint union unlock unsigned until ushort using va_arg va_first val valint vallng valuint valulng va_next var varptr view virtual wait wbin wchr weekday weekdayname wend whex while width win32 window windowtitle winput with woct write wspace wstr wstring xor year zstring
preprocessor=#assert #define defined #else #elseif #endif #endmacro #error #if #ifdef #ifndef #inclib #include #lang #libpath #line #macro once #pragma #print typeof #undef
# user definable keywords
user1=
user2=

[settings]
# default extension used when saving files
extension=bas

# the following characters are these which a "word" can contains, see documentation
#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

# single comments, like # in this file
comment_single='
# multiline comments
comment_open=/'
comment_close='/

# set to false if a comment character/string should start at column 0 of a line, true uses any
# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d
	#command_example();
# setting to false would generate this
#	command_example();
# This setting works only for single line comments
comment_use_indent=true

# context action command (please see Geany's main documentation for details)
context_action_cmd=

[indentation]
#width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
#type=1

[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension
# (use only one of it at one time)
compiler=fbc -w all "%f"
run_cmd="./%e"

Maybe we can add even more for proper highlighting. :-)

Works, tested.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: FLTK-C-1.3.3 for FreeBASIC

Post by bcohio2001 »

Thanks for looking into this for me.
I am sorry, I forgot all about the defined variables in the If/Then checks. Was not expecting for you to run it, just look it over to see if I did something wrong.

Ok. So "Win32" cannot be used as a variable. (Assuming will be fine now in 64 bit compile if changed)
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

Seems i got programming fever 41° now. I have taken most important keywords beginning with "Fl_" from FLTK and from FB into your syntax highlighter, Joshy.

Code: Select all

' syntax_highlighter.bas
' syntax highlighting for FreeBASIC 1.06
' and Fltk 1.3.3
' with most important keywords

#include once "fltk-c.bi"
#include once "crt/stdlib.bi"
#include once "crt/string.bi"

#define FONTSIZE 14
#define STYLE_PLAIN    asc("A")
#define STYLE_KEYWORD  asc("B")
#define STYLE_STRING   asc("C")
#define STYLE_COMMENT  asc("D")
#define STYLE_NUMBER   asc("E")
#define STYLE_PREPROC  asc("F")
#define STYLE_DATATYPE asc("G")
#define STYLE_OTHER    asc("H")
#define STYLE_USERLIB  asc("I")

dim as Style_Table_Entry StyleTable(...) => _
{(FL_BLACK        ,FL_TIMES         ,FONTSIZE), _ ' style 'A'
 (FL_DARK_GREEN   ,Fl_TIMES_BOLD    ,FONTSIZE), _ ' style 'B'
 (FL_DARK_MAGENTA ,Fl_COURIER       ,FONTSIZE), _ ' style 'C'
 (Fl_RED          ,Fl_COURIER_ITALIC,FONTSIZE), _ ' style 'D'
 (FL_BLACK        ,Fl_COURIER_BOLD  ,FONTSIZE), _ ' style 'E'
 (FL_BLUE         ,Fl_COURIER_BOLD  ,FONTSIZE), _ ' style 'F'
 (FL_DARK_CYAN    ,Fl_COURIER       ,FONTSIZE), _ ' style 'G'
 (FL_LIGHT2       ,Fl_COURIER_BOLD  ,FONTSIZE), _ ' style 'H'
 (FL_MAGENTA      ,Fl_COURIER       ,FONTSIZE)}   ' style 'I'

' test of simple float (without E notation)
dim as single f1 = 1.234
dim as single f2 = .123
' test of dec, hex, oct, bin numbers
dim as integer d = 123456, h = &h123abc, o = &o1234567, b = &b00110010

function IsWhite(byval c as ubyte) as long
  if c=32 then return 1
  if c= 9 then return 1
  return 0
end function

function IsAlpha(byval c as ubyte) as long
  select case as const c
  case asc("a") to asc("z") : return 1
  case asc("A") to asc("Z") : return 1
  case asc("_") : return 1
  end select
  return 0
end function

function IsNumber(byval c as ubyte) as long
  select case as const c
  case asc("0") to asc("9") : return 1
  end select
  return 0
end function

function IsHex(byval c as ubyte) as long
  select case as const c
  case asc("a") to asc("f") : return 1
  case asc("A") to asc("F") : return 1
  end select
  return IsNumber(c)
end function

function IsOct(byval c as ubyte) as long
  select case as const c
  case asc("0") to asc("7") : return 1
  end select
  return 0
end function

function IsBin(byval c as ubyte) as long
  select case as const c
  case asc("0"),asc("1") : return 1
  end select
  return 0
end function

function IsAlphaNum(byval c as ubyte) as long
  If IsAlpha(c) then return 1
  If IsNumber(c) then return 1
  return 0
end function

function IsOperator(byval c as ubyte) as long
  return instr("=<>-+*/\@",chr(c))
end function

function IsDelimiter(byval c as ubyte) as long
  if c=10 then return 1
  if c=13 then return 1
  if c=34 then return 1
  if instr(",:()[]{}",chr(c)) then return 1
  return IsOperator(c)
end function

' almost all fb keywords
function IsKeyword(byval s as string) as long
  dim as string search = "," & lcase(s) & ","
  dim as ubyte char=search[1]
  
  return instr(",abs,access,acos,add,alias,allocate,alpha,and,andalso,any,append,as,asc," & _
  "asin,asm,assert,assertwarn,atan2,atn,base,beep,bin,binary,bit,bitreset,bitset,bload," & _
  "boolean,bsave,byref,byte,byval,call,callocate,case,cast,cbool,cbyte,cdbl,cdecl,chain," & _
  "chdir,chr,cint,circle,class,clear,clng,clngint,close,cls,color,com,command,common," & _
  "condbroadcast,condcreate,conddestroy,condsignal,condwait,cons,const,constructor,continue," & _
  "cos,cptr,cshort,csign,csng,csrlin,cubyte,cuint,culng,culngint,cunsg,curdir,cushort,custom," & _
  "cvd,cvi,cvl,cvlongint,cvs,cvshort,data,date,dateadd,datediff,datepart,dateserial,datevalue," & _
  "day,deallocate,declare,defbyte,defdbl,defint,deflng,deflngint,defshort,defsng,defstr," & _
  "defubyte,defuint,defulngint,defushort,delete,destructor,dim,dir,do,double,draw,dylibfree," & _
  "dylibload,dylibsymbol,dynamic,else,elseif,encoding,end,endif,enum,environ,eof,eqv,erase," & _
  "erfn,erl,ermn,err,error,escape,exec,exepath,exit,exp,explicit,export,extends,extern,false," & _
  "fboolean,field,fileattr,filecopy,filedatetime,fileexists,filelen,fix,flip,for,format,frac," & _
  "fre,freefile,function,get,getjoystick,getkey,getmouse,gosub,goto,hex,hibyte,hiword,hour,if," & _
  "iif,imageconvertrow,imagecreate,imagedestroy,imp,import,inkey,inp,input,input$,instr," & _
  "instrrev,int,integer,interface,is,isdate,kill,lbound,lcase,left,len,let,lib,line,lobyte,loc," & _
  "local,locate,lock,lof,log,long,longint,loop,loword,lpos,lprint,lpt,lset,ltrim,mid,minute,mkd," & _
  "mkdir,mki,mkl,mklongint,mks,mkshort,mod,month,monthname,multikey,mutexcreate,mutexdestroy," & _
  "mutexlock,mutexunlock,name,namespace,new,next,nokeyword,not,now,object,oct,offsetof,on,once," & _
  "open,operator,option,or,orelse,out,output,overload,paint,palette,pascal,pcopy,peek,pipe," & _
  "pmap,point,pointer,poke,pos,preserve,preset,print,private,procptr,property,protected,pset," & _
  "ptr,public,put,random,randomize,read,reallocate,redim,rem,reset,restore,resume,return,rgb," & _
  "rgba,right,rmdir,rnd,rset,rtrim,run,sadd,scope,screen,screencontrol,screencopy,screenevent," & _
  "screenglproc,screeninfo,screenlist,screenlock,screenptr,screenres,screenset,screensync," & _
  "screenunlock,scrn,second,seek,select,setdate,setenviron,setmouse,settime,sgn,shared,shell,shl," & _
  "short,shr,sin,single,sizeof,sleep,space,spc,sqr,static,stdcall,step,stop,str,string,strptr," & _
  "sub,swap,system,tab,tan,then,this,threadcreate,threadwait,time,timer,timeserial,timevalue,to," & _
  "trans,trim,true,type,ubound,ubyte,ucase,uinteger,ulong,ulongint,union,unlock,unsigned,until," & _
  "ushort,using,va_arg,va_first,val,valint,vallng,valuint,valulng,va_next,var,varptr,view,virtual," & _
  "wait,wbin,wchr,weekday,weekdayname,wend,whex,while,width,win32,window,windowtitle,winput,with," & _
  "woct,write,wspace,wstr,wstring,xor,year,zstring,", search)
  return 0
end function

' data words
function IsDatatype(byval s as string) as long
  dim as string search = "," & lcase(s) & ","
  return instr(",as,byref,byte,byval,boolean,const,double,long,long,longint,ptr,pointer,short,single,string," & _
  "ubyte,ulong,ulong,ulongint,ushort,wstring,,zstring,", search)
  return 0
end function

' preprocessor
function IsPreproc(byval s as string) as long
  dim as string search = "," & ucase(s) & ","
  dim as ubyte char=search[1]
  select case as const char
    case asc("#") : return instr(",#ASSERT,#DEFINE,#ELSE,#ELSEIF,#ENDIF,#ENDMACRO,#ERROR,#IF,#IFDEF,#IFNDEF,#INCLIB,#INCLUDE," & _
                            "#LANG,#LIBPATH,#LINE,#MACRO,#PRAGMA,#PRINT,#UNDEF,", search)
    case asc("_") : return instr(",__DATE_ISO__, __DATE__, __FB_64BIT__,  __FB_ARGC__, __FB_ARGV__, __FB_BACKEND__, __FB_BIGENDIAN__," & _
    "__FB_BUILD_DATE__, __FB_CYGWIN__, __FB_DARWIN__, __FB_DEBUG__,  __FB_DOS__, __FB_ERR__, __FB_FPMODE__, __FB_FPU__, __FB_FREEBSD__," & _
    "__FB_GCC__, __FB_LANG__, __FB_LINUX__, __FB_MAIN__, __FB_MIN_VERSION__, __FB_MT__, __FB_NETBSD__,  __FB_OPENBSD__," &  _
    "__FB_OPTION_BYVAL__, , __FB_OPTION_ESCAPE__, __FB_OPTION_EXPLICIT__, __FB_OPTION_GOSUB__, __FB_OPTION_PRIVATE__," & _
    "__FB_OUT_DLL__, __FB_OUT_EXE__, __FB_OUT_LIB__, __FB_OUT_OBJ__, __FB_PCOS__, __FB_SIGNATURE__, __FB_SSE__, __FB_UNIX__," &  _
    "__FB_VECTORIZE__, , , __FB_VER_MINOR__, __FB_VER_PATCH__, __FB_WIN32__, __FB_XBOX__, __FILE_NQ__, __FILE__," &  _
    "__FUNCTION_NQ__, , , __PATH__, __TIME__,", search)
    case else : return instr(",DEFINED,ONCE,TYPEOF,", search)
  end select
end function

' some FLTK stuff
function IsUserlib(byval s as string) as long
  if len(s)<5 then return 0
  
  dim as string search = "," & lcase(s) & ","
  
   ' most common fltk words
  if instr(",fl_run,fl_windowshow,fl_windownew,fl_windownew2,fl_double_windownew,fl_double_windownew2,fl_getw,fl_geth," & _
  "fl_text_editornew,fl_widgetgetw,fl_widgetgeth,fl_text_buffernew,fl_widgetsetuserdata,fl_text_displaysetlinenumberwidth," & _
  "fl_text_displaysetbuffer,fl_text_displayhighlightdata,fl_text_bufferloadfile,fl_text_buffersettext," & _
  "fl_text_editor ptr editor,fl_text_buffer,fl_text_displaygetbuffer,fl_widgetgetuserdata," & _
  "fl_text_bufferreplace,fl_text_bufferremove,fl_text_bufferselect,fl_text_bufferlinestart,fl_text_bufferlength," & _
  "fl_text_bufferlineend,fl_text_buffertextrange,fl_text_bufferreplace," & _
  "fl_groupsetresizable,",search) then return 1
  
  
  dim as ubyte char=search[4]
  select case as const char
  
  case asc("a") : return instr(",fl_access,fl_addawakehandler,fl_adjuster,fl_adjustergetsoft,fl_adjusternew,fl_align,fl_align_bottom," & _
  "fl_align_bottom_left,fl_align_bottom_right,fl_align_center,fl_align_clip,fl_align_image_backdrop,fl_align_image_mask," & _
  "fl_align_image_next_to_text,fl_align_image_over_text,fl_align_inside,fl_align_left,fl_align_left_bottom,fl_align_left_top," & _
  "fl_align_position_mask,fl_align_right,fl_align_right_bottom,fl_align_right_top,fl_align_text_next_to_image," & _
  "fl_align_text_over_image,fl_align_top,fl_align_top_left,fl_align_top_right,fl_align_wrap,fl_alt,fl_alt_l,fl_alt_r," & _
  "fl_args_handler,fl_atclose_handler,fl_awake_handler,fl_awake2,",search) 

  case asc("b") : return instr(",fl_back,fl_background_color,fl_background2_color,fl_backspace,fl_bep,fl_beep_default," & _
  "fl_beep_error,fl_beep_message,fl_beep_notification,fl_beep_password,fl_beep_question,fl_bitmap,fl_bitmapcopy," & _
  "fl_bitmapcopy2,fl_bitmapnew,fl_black,fl_blue,fl_bmp_image,fl_bmp_imagenew,fl_bold,fl_bold_italic,fl_border_box," & _
  "fl_border_frame,fl_bottom,fl_box,fl_box_draw_f,fl_boxdh,fl_boxdw,fl_boxdx,fl_boxdy,fl_boxhandle,fl_boxnew," & _
  "fl_boxnew2,fl_boxtype,fl_browser	,fl_browser_begin,fl_browser_deselect,fl_browser_end,fl_browser_gethassscrollbar," & _
  "fl_browser_gethposition,fl_browser_getposition,fl_browser_getscrollbarsize,fl_browser_getscrollbarwidth," & _
  "fl_browser_gettextcolor,fl_browser_gettextfont,fl_browser_gettextsize,fl_browser_handle,fl_browser_select," & _
  "fl_browser_selectonly,fl_browserdisplayed,fl_browserend,fl_browsergetcolumnchar,fl_browsergetcolumnwidths," & _
  "fl_browsergetdata,fl_browsergetformatchar,fl_browsergeticon,fl_browsergetsize,fl_browsergettext,fl_browsergettopline," & _
  "fl_browsergetvalue,fl_browserload,fl_browsernew,fl_browserselect,fl_browserselected,fl_browsertype,fl_browservisible," & _
  "fl_button,fl_button1,fl_button2,fl_button3,fl_buttonclear,fl_buttongetdownbox,fl_buttongetdowncolor,fl_buttongetshortcut," & _
  "fl_buttongetvalue,fl_buttonhandle,fl_buttonnew,fl_buttons,fl_buttonset,fl_buttonsetvalue,",search) 

  case asc("c") : return instr(",fl_callback,fl_callback_p,fl_callback0,fl_callback1,fl_canvas,fl_canvasdraw,fl_canvashandlebase," & _
  "fl_canvasnew,fl_cap_flat,fl_cap_round,fl_cap_square,fl_caps_lock,fl_capslock,fl_char,fl_chart,fl_chart_bar,fl_chart_fill," & _
  "fl_chart_horbar,fl_chart_line,fl_chart_pie,fl_chart_specialpie,fl_chart_spike,fl_chartgetautosize,fl_chartgetmaxsize," & _
  "fl_chartgetsize,fl_chartgettextcolor,fl_chartgettextfont,fl_chartgettextsize,fl_chartnew,fl_charttype,fl_check,fl_check_browser," & _
  "fl_check_browseradd,fl_check_browseradd2,fl_check_browsergetchecked,fl_check_browsernchecked,fl_check_browsernew," & _
  "fl_check_browsernitems,fl_check_browserremove,fl_check_browsertext,fl_check_browservalue,fl_check_button,fl_check_buttonnew," & _
  "fl_chmod,fl_choice,fl_choicegetvalue,fl_choicehandle,fl_choicenew,fl_choicesetvalue,fl_choicesetvaluebyitem,fl_clipboard_image," & _
  "fl_clipboard_notify_handler,fl_clipboard_plain_text,fl_clock,fl_clock_output,fl_clock_outputgetvalue,fl_clock_outputhour," & _
  ",fl_clock_outputnew,fl_clock_outputsecond,fl_clock_round,fl_clock_square,fl_clocknew,fl_clocknew2,fl_clocktype,fl_color," & _
  "fl_color,fl_color_average,fl_color_chooser,fl_color_chooserb,fl_color_chooserg,fl_color_choosergetmode,fl_color_chooserhsv," & _
  "fl_color_chooserhue,fl_color_choosernew,fl_color_chooserr,fl_color_chooserrgb,fl_color_choosersaturation,fl_color_chooservalue," & _
  "fl_color_cube,fl_colorchooser_byte,fl_colorchooser_default,fl_colorchooser_hex,fl_colorchooser_hsv,fl_colorchooser_rgb," & _
  "fl_colorchoosermodes,fl_command,fl_compose,fl_context_cell,fl_context_col_header,fl_context_endpage,fl_context_none," & _
  "fl_context_rc_resize,fl_context_row_header,fl_context_startpage,fl_context_table,fl_contrast,fl_control,fl_control_l," & _
  "fl_control_r,fl_copy_surface,fl_copy_surfaceclassname,fl_copy_surfacedelete,fl_copy_surfacegetdriver,fl_copy_surfacenew," & _
  "fl_counter,fl_counter_normal,fl_counter_simple,fl_counterhandle,fl_counternew,fl_countertype,fl_courier,fl_courier_bold," & _
  "fl_courier_bold_italic,fl_courier_italic,fl_cstring,fl_ctrl,fl_ctrl,fl_cursor,fl_cursor_arrow,fl_cursor_cross," & _
  "fl_cursor_default,fl_cursor_e,fl_cursor_hand,fl_cursor_help,fl_cursor_insert,fl_cursor_move,fl_cursor_n,fl_cursor_ne," & _
  ",fl_cursor_none,fl_cursor_ns,fl_cursor_nw,fl_cursor_nwse,fl_cursor_s,fl_cursor_se,fl_cursor_sw,fl_cursor_w,fl_cursor_wait," & _
  "fl_cursor_we,fl_cyan,",search)

  case asc("d") : return instr(",fl_damage,fl_damage_all,fl_damage_child,fl_damage_expose,fl_damage_overlay,fl_damage_scroll," & _
  "fl_damage_user1,fl_damage_user2,fl_dark_blue,fl_dark_cyan,fl_dark_green,fl_dark_magenta,fl_dark_red,fl_dark_yellow,fl_dark1," & _
  "fl_dark2,fl_dark3,fl_dash,fl_dashdot,fl_dashdotdot,fl_dataopcode,fl_delete,fl_destructorex,fl_device,fl_device_asany," & _
  "fl_dial,fl_dial_fill,fl_dial_line,fl_dial_normal,fl_dialgetangle1,fl_dialgetangle2,fl_dialhandle,fl_dialnew,fl_dialtype," & _
  "fl_diamond_down_box,fl_diamond_up_box,fl_directories,fl_dnd,fl_dot,fl_double_window,fl_double_windowex," & _
  "fl_double_windowexhandlebase,fl_double_windowexnew,fl_double_windowexnew2,fl_double_windownew,fl_double_windownew2," & _
  "fl_down,fl_down_box,fl_down_frame,fl_draw_image_cb,fl_draw_overlayex,fl_drawboxactive,fl_drawcellex,fl_drawex," & _
  "fl_double_windowshow,",search)
  
  case asc("e") : return instr(",fl_embossed_box,fl_embossed_frame,fl_end,fl_engraved_box,fl_engraved_frame,fl_enter_key," & _
  "fl_escape,fl_event,fl_event_activate,fl_event_button,fl_event_close,fl_event_deactivate,fl_event_dispatch," & _
  "fl_event_dnd_drag,fl_event_dnd_enter,fl_event_dnd_leave,fl_event_dnd_release,fl_event_drag,fl_event_enter," & _
  "fl_event_focus,fl_event_fullscreen,fl_event_handler,fl_event_hide,fl_event_keyboard,fl_event_keydown," & _
  "fl_event_keyup,fl_event_leave,fl_event_mousewheel,fl_event_move,fl_event_paste,fl_event_push," & _
  "fl_event_release,fl_event_screen_configuration_changed,fl_event_selectionclear,fl_event_shortcut,fl_event_show," & _
  "fl_event_states,fl_event_unfocus,fl_except,fl_execvp,fl_extends1,fl_extends2,fl_extends3,fl_extends4,fl_extends5,",search)
  
  case asc("f") : return instr(",fl_f,fl_f_last,fl_favorites,fl_fd_handler,fl_file_browser,fl_file_browser),fl_file_browsergetfiletype," & _
  "fl_le_browsergetfilter,fl_file_browsergeticonsize,fl_file_browsergettextsize,fl_file_browserload,fl_file_browsernew,fl_file_chooser," & _
  "fl_file_chooseraddextra,fl_file_choosercount,fl_file_choosergetcolor,fl_file_choosergetdirectory,fl_file_choosergetfilter," & _
  "fl_file_choosergetfiltervalue,fl_file_choosergeticonsize,fl_file_choosergetlabel,fl_file_choosergetoklabel," & _
  "fl_file_choosergetpreview,fl_file_choosersetpreview,fl_file_chooserrescankeepfilename," & _
  "fl_file_choosergettextcolor,fl_file_choosergettextfont,fl_file_choosergettextsize,fl_file_choosergettype,fl_file_choosergetuserdata," & _
  "fl_file_choosergetvalue,fl_file_choosernew,fl_file_choosernewbutton,fl_file_chooserpreviewbutton,fl_file_choosershowhiddenbutton," & _
  "fl_file_choosershown,fl_file_chooservisible,fl_file_chose_cb,fl_file_icon,fl_file_iconadd,fl_file_iconaddcolor,fl_file_iconaddvertex," & _
  "fl_file_iconaddvertex2,fl_file_iconfind,fl_file_iconfirst,fl_file_iconloadfti,fl_file_iconloadimage,fl_file_iconnew,fl_file_iconnext," & _
  "fl_file_iconpattern,fl_file_iconsize,fl_file_icontype,fl_file_iconvalue,fl_file_input,fl_file_inputgetdownbox,fl_file_inputgeterrorcolor," & _
  "fl_file_inputgetvalue,fl_file_inputhandle,fl_file_inputnew,fl_file_inputsetvalue,fl_file_inputsetvalue2,fl_file_sort_f,fl_file_type," & _
  "fl_filechooser_create,fl_filechooser_directory,fl_filechooser_multi,fl_filechooser_single,fl_filechooser_type,fl_fileicon_type," & _
  "fl_files,fl_fill_dial,fl_fill_dialnew,fl_fill_slider	,fl_fill_slidernew,fl_find,fl_flat_box,fl_float_input,fl_float_inputnew," & _
  "fl_font,fl_fontsize,fl_fontsize,fl_fopen,fl_foreground_color,fl_forward,fl_free_color,fl_free_font,",search) 
  
  case asc("g") : return instr(",fl_getawakehandler_,fl_getbelowmouse,fl_getboxtype,fl_getcolor2,fl_getcwd,fl_getdamage,fl_getdndtextops," & _
  "fl_getdrawshortcutflag,fl_getenv,fl_getfirstwindow,fl_getfocus,fl_getfontname,fl_getfontsizes,fl_getgrab,fl_geth,fl_getpushed," & _
  "fl_getscheme,fl_getscrollbarsize,fl_getshortcutlabel,fl_getvisiblefocus,fl_getw,fl_getx,fl_gety,fl_gif_image,fl_gif_imagenew," & _
  "fl_gleam_down_box,fl_gleam_down_frame,fl_gleam_round_down_box,fl_gleam_round_up_box,fl_gleam_thin_down_box,fl_gleam_thin_up_box," & _
  "fl_gleam_up_box,fl_gleam_up_frame,fl_graphics_driver,fl_graphics_driverclassname,fl_gray,fl_gray_color,fl_gray_ramp,fl_gray0," & _
  "fl_green,fl_group,fl_grouparray,fl_grouparray2,fl_groupasgroup,fl_groupbegin,fl_groupchild,fl_groupchildren,fl_groupconstarray," & _
  "fl_groupend,fl_groupfind,fl_groupgetclipchildren,fl_groupgetresizable,fl_grouphandle,fl_groupnew,fl_groupresizeable," & _
  "fl_groupsetresizable,fl_gtk_down_box,fl_gtk_down_frame,fl_gtk_round_down_box,fl_gtk_round_up_box,fl_gtk_thin_down_box," & _
  "fl_gtk_thin_down_frame,fl_gtk_thin_up_box,fl_gtk_thin_up_frame,fl_gtk_up_box,fl_gtk_up_frame,",search) 
  
  case asc("h") : return instr(",fl_handle,fl_handleex,fl_hascheck,fl_hasidle,fl_hastimeout,fl_help,fl_help_f,fl_help_view," & _
  "fl_help_viewdirectory,fl_help_viewfilename,fl_help_viewfind,fl_help_viewgetleftline,fl_help_viewgetscrollbarsize," & _
  "fl_help_viewgetsize,fl_help_viewgettextcolor,fl_help_viewgettextfont,fl_help_viewgettextsize,fl_help_viewgettopline," & _
  "fl_help_viewgetvalue,fl_help_viewload,fl_help_viewnew,fl_help_viewtitle,fl_helvetica,fl_helvetica_bold," & _
  "fl_helvetica_bold_italic,fl_helvetica_italic,fl_hold_browser,fl_hold_browsernew,fl_holdbrowser,fl_home,fl_home_page," & _
  "fl_hor_fill_slider,fl_hor_fill_slidernew,fl_hor_nice_slider,fl_hor_nice_slidernew,fl_hor_slider,fl_hor_slidernew," & _
  "fl_hor_value_slider,fl_hor_value_slidernew,",search)
  
  case asc("i") : return instr(",fl_icon_color,fl_idle_handler,fl_image,fl_image_surface,fl_image_surfaceclassname," & _
  "fl_image_surfacegetdriver,fl_image_surfaceimage,fl_image_surfacenew,fl_image_with_alpha,fl_image_asany,fl_imagecopy," & _
  "fl_imagecopy2,fl_imagecount,fl_imaged,fl_imagedata,fl_imagegetbytesperpixel,fl_imagegetheight,fl_imagegetpitch," & _
  "fl_imagegetwidth,fl_imageh,fl_imageld,fl_imagenew,fl_imagew,fl_inactive,fl_inactive_color,fl_input,fl_input_," & _
  "fl_input_choice,fl_input_choicechanged,fl_input_choicegetdownbox,fl_input_choicegetmenu,fl_input_choicegettextcolor," & _
  "fl_input_choicegettextfont,fl_input_choicegettextsize,fl_input_choicegetvalue,fl_input_choiceinput,fl_input_choicemenubutton," & _
  "fl_input_choicenew,fl_input_copy,fl_input_copycuts,fl_input_cut,fl_input_cut1,fl_input_cut2,fl_input_float," & _
  "fl_input_getcursorcolor,fl_input_getinputtype,fl_input_getmark,fl_input_getmaximumsize,fl_input_getposition," & _
  "fl_input_getreadonly,fl_input_getshortcut,fl_input_getsize,fl_input_gettabnav,fl_input_gettextcolor," & _
  "fl_input_gettextfont,fl_input_gettextsize,fl_input_getvalue,fl_input_getwrap,fl_input_index,fl_input_insert," & _
  "fl_input_int,fl_input_multiline,fl_input_multiline_output,fl_input_multiline_output_wrap,fl_input_multiline_wrap," & _
  "fl_input_normal,fl_input_normal_output,fl_input_readonly,fl_input_replace,fl_input_secret,fl_input_setmark," & _
  "fl_input_setposition,fl_input_setposition2,fl_input_setvalue,fl_input_setvalue2,fl_input_staticvalue,fl_input_staticvalue2," & _
  "fl_input_type,fl_input_undo,fl_input_wrap,fl_inputhandle,fl_inputnew,fl_insert,fl_int_input,fl_int_inputnew,fl_iso_key," & _
  "fl_isscheme,fl_italic,",search)
  
  case asc("j") : return instr(",fl_join_bevel,fl_join_miter,fl_join_round,fl_jpeg_image,fl_jpeg_imagedelete," & _
  "fl_jpeg_imagemem,fl_jpeg_imagenew,fl_jpg_imagedelete,fl_jpg_imagemem,fl_jpg_imagenew,",search) 
  
  case asc("k") : return instr(",fl_key_mask,fl_kp,fl_kp_enter,fl_kp_last,",search)
  
  case asc("l") : return instr(",fl_label_draw_f,fl_label_embossed,fl_label_engraved,fl_label_free,fl_label_icon,fl_label_image," & _
  "fl_label_measure_f,fl_label_multi,fl_label_no,fl_label_normal,fl_label_shadow,fl_label_symbol,fl_label_type,fl_left," & _
  "fl_left_mouse,fl_light_button,fl_light_buttonhandle,fl_light_buttonnew,fl_light1,fl_light2,fl_light3,fl_line_dial," & _
  "fl_line_dialnew,fl_line_position,fl_line_style,fl_lock,",search) 
  
  case asc("m") : return instr(",fl_magenta,fl_mail,fl_make_path,fl_max_path,fl_media_next,fl_media_play,fl_media_prev," & _
  "fl_media_stop,fl_menu,fl_menu_,fl_menu_add,fl_menu_add2,fl_menu_add3,fl_menu_bar,fl_menu_barhandle,fl_menu_barnew," & _
  "fl_menu_button,fl_menu_buttonhandle,fl_menu_buttonnew,fl_menu_buttonpopup,fl_menu_clearsubmenu,fl_menu_divider," & _
  "fl_menu_findindexbycallback,fl_menu_findindexbyitem,fl_menu_findindexbyname,fl_menu_finditembycallback," & _
  "fl_menu_finditembyname,fl_menu_getdownbox,fl_menu_getdowncolor,fl_menu_getmenu,fl_menu_getmode,fl_menu_getsize," & _
  "fl_menu_gettextcolor,fl_menu_gettextfont,fl_menu_gettextsize,fl_menu_getvalue,fl_menu_getvaluebyindex," & _
  "fl_menu_getvaluebyitem,fl_menu_horizontal,fl_menu_inactive,fl_menu_insert,fl_menu_insert2,fl_menu_invisible," & _
  "fl_menu_item,fl_menu_itemactive,fl_menu_itemactivevisible,fl_menu_itemadd,fl_menu_itemadd2,fl_menu_itemcheckbox," & _
  "fl_menu_itemchecked,fl_menu_itemfindshortcut,fl_menu_itemfirst,fl_menu_itemfirst2,fl_menu_itemgetargument," & _
  "fl_menu_itemgetcallback_p,fl_menu_itemgetlabel,fl_menu_itemgetlabelcolor,fl_menu_itemgetlabelfont," & _
  "fl_menu_itemgetlabelsize,fl_menu_itemgetlabeltype,fl_menu_itemgetshortcut,fl_menu_itemgetuserdata," & _
  "fl_menu_iteminsert,fl_menu_itemmeasure,fl_menu_itemnext,fl_menu_itemnext2,fl_menu_itempathname,fl_menu_itempopup," & _
  "fl_menu_itempulldown,fl_menu_itemradio,fl_menu_itemsize,fl_menu_itemsubmenu,fl_menu_itemtestshortcut," & _
  "fl_menu_itemvalue,fl_menu_itemvisible,fl_menu_mvalue,fl_menu_picked,fl_menu_radio,fl_menu_testshortcut," & _
  "fl_menu_text,fl_menu_textbyindex,fl_menu_toggle,fl_menu_value,fl_menu_window,fl_menu_windowex," & _
  "fl_menu_windowexhandlebase,fl_menu_windowexnew,fl_menu_windowexnew2,fl_menu_windownew,fl_menu_windownew2," & _
  "fl_menu_windowoverlay,fl_menubutton_popup_type,fl_menuitem_flag,fl_meta,fl_meta,fl_meta_l,fl_meta_r," & _
  "fl_middle,fl_middle_mouse,fl_mkdir,fl_modal,fl_mouse_button,fl_mouse_keyboard_events,fl_mousebutton," & _
  "fl_multi_browser,fl_multi_browsernew,fl_multibrowser,fl_multiline_input,fl_multiline_input),fl_multiline_inputnew," & _
  "fl_multiline_output,fl_multiline_outputnew,",search)
  
  case asc("n") : return instr(",fl_native_file_chooser,fl_native_file_choosercount,fl_native_file_choosererrormsg," & _
  "fl_native_file_chooserfilename,fl_native_file_choosergetdirectory,fl_native_file_choosergetfilename," & _
  "fl_native_file_choosergetfilter,fl_native_file_choosergetfiltervalue,fl_native_file_choosergetoptions," & _
  "fl_native_file_choosergetpresetfile,fl_native_file_choosergettitle,fl_native_file_choosergettype,fl_native_file_choosernew," & _
  "fl_native_file_choosershow,fl_nextwindow,fl_nfc_option,fl_nfc_type,fl_nice_slider,fl_nice_slidernew,fl_no_box,fl_nonspacing," & _
  "fl_normal_size,fl_normalbrowser,fl_num_blue,fl_num_free_color,fl_num_gray,fl_num_green,fl_num_lock,fl_num_red,fl_numlock,",search)
  
  case asc("o") : return instr("fl_oflat_box,fl_old_idle_handler,fl_open,fl_option,fl_option_arrow_focus,fl_option_dnd_text," & _
  "fl_option_fnfc_uses_gtk,fl_option_last,fl_option_show_tooltips,fl_option_visible_focus,fl_oshadow_box,fl_output,fl_outputnew," & _
  "fl_oval_box,fl_oval_frame,fl_overlay_window,fl_overlay_windowcandooverlay,fl_overlay_windowex,fl_overlay_windowexhandlebase," & _
  "fl_overlay_windowexnew	,fl_overlay_windowexnew2,",search)
  
  case asc("p") : return instr(",fl_pack,fl_pack_horizontal,fl_pack_type,fl_pack_vertical,fl_packbegin,fl_packend,fl_packgetspacing," & _
  "fl_packnew,fl_page_down,fl_page_up,fl_paged_device,fl_paged_deviceformatheight,fl_paged_deviceformatwidht," & _
  "fl_paged_devicegetformatname,fl_pause,fl_pixmap,fl_pixmapcopy,fl_pixmapcopy2,fl_pixmapnew,fl_plastic_down_box," & _
  "fl_plastic_down_frame,fl_plastic_round_down_box,fl_plastic_round_up_box,fl_plastic_thin_down_box,fl_plastic_thin_up_box," & _
  "fl_plastic_up_box,fl_plastic_up_frame,fl_png_image,fl_png_imagemem,fl_png_imagenew,fl_pnm_image,fl_pnm_imagenew," & _
  "fl_preferences,fl_preferencesclear,fl_preferencesdeleteallentries,fl_preferencesdeleteallgroups,fl_preferencesdeleteentry," & _
  "fl_preferencesdeletegroup,fl_preferencesentries,fl_preferencesentry,fl_preferencesentryexists,fl_preferencesentryname," & _
  "fl_preferencesentrypath,fl_preferencesgetdata,fl_preferencesgetdata2,fl_preferencesgetdouble,fl_preferencesgetfloat," & _
  "fl_preferencesgetint,fl_preferencesgetsize,fl_preferencesgetstring,fl_preferencesgetstring2,fl_preferencesgetuserdatapath," & _
  "fl_preferencesgroup,fl_preferencesgroupexists,fl_preferencesgroups,fl_preferencesnew,fl_preferencesnew2," & _
  "fl_preferencesnewchildgroup,fl_preferencesnewgroup,fl_preferencesnewgroup2,fl_preferencessetdata,fl_preferencessetdouble," & _
  "fl_preferencessetdouble2,fl_preferencessetfloat,fl_preferencessetfloat2,fl_preferencessetint,fl_preferencessetstring," & _
  "fl_print,fl_printer,fl_printerclassname,fl_printerendpage,fl_printergetdriver,fl_printergetprintablerect,fl_printernew," & _
  "fl_printerstartjob,fl_printerstartpage,fl_progress,fl_progressgetmaximum,fl_progressgetminimum,fl_progressgetvalue,fl_progressnew,",search)
   
  case asc("r") : return instr(",fl_radio_button,fl_radio_buttonnew,fl_radio_light_button,fl_radio_light_buttonnew," & _
  "fl_radio_round_button,fl_radio_round_buttonnew,fl_read,fl_readqueue,fl_ready,fl_red,fl_refresh,fl_reloadscheme," & _
  "fl_rename,fl_repeat_button,fl_repeat_buttonhandle,fl_repeat_buttonnew,fl_reserved_type,fl_resizeex,fl_return_button," & _
  "fl_return_buttonhandle,fl_return_buttonnew,fl_rflat_box,fl_rgb_color,fl_rgb_image,fl_rgb_imagecopy,fl_rgb_imagecopy2," & _
  "fl_rgb_imagenew,fl_right,fl_right_mouse,fl_rmdir,fl_roller,fl_rollernew,fl_root,fl_root_system,fl_root_user," & _
  "fl_round_button,fl_round_buttonnew,fl_round_clock,fl_round_clocknew,fl_round_down_box,fl_round_up_box," & _
  "fl_rounded_box,fl_rounded_frame,fl_rshadow_box,fl_run,",search) 
  
  case asc("s") : return instr(",fl_screen,fl_screen_bold,fl_screencount,fl_screenheight,fl_screenwidth,fl_screenx,fl_screeny,fl_scroll," & _
  "fl_scroll_always_on,fl_scroll_both,fl_scroll_both_always,fl_scroll_horizontal,fl_scroll_horizontal_always,fl_scroll_lock,fl_scroll_no," & _
  "fl_scroll_type,fl_scroll_vertical,fl_scroll_vertical_always,fl_scrollbar,fl_scrollbargetlinesize,fl_scrollbargetvalue,fl_scrollbarhandle," & _
  "fl_scrollbarnew,fl_scrollbarsetvalue,fl_scrollbarvalue,fl_scrollbegin,fl_scrollend,fl_scrollgetscrollbarsize,fl_scrollhandle," & _
  "fl_scrollhscrollbar,fl_scrolllock,fl_scrollnew,fl_scrollscrollbar,fl_scrollxposition,fl_scrollyposition,fl_search,fl_secret_input," & _
  "fl_secret_inputhandle,fl_secret_inputnew,fl_select_browser,fl_select_browsernew,fl_select_multi,fl_select_none,fl_select_single," & _
  "fl_selectbrowser,fl_selection_color,fl_setfonts,fl_setscheme,fl_shadow_box,fl_shadow_frame,fl_shared_handler,fl_shared_image," & _
  "fl_shared_imagecopy,fl_shared_imagecopy2,fl_shared_imagefind,fl_shared_imageget,fl_shared_imageimages,fl_shared_imagename," & _
  "fl_shared_imagenumimages,fl_shared_imagerefcount,fl_shift,fl_shift_l,fl_shift_r,fl_shortcut,fl_simple_counter," & _
  "fl_simple_counternew,fl_single_window,fl_single_windowex,fl_single_windowexhandlebase,fl_single_windowexnew,fl_single_windowexnew2," & _
  "fl_single_windownew,fl_single_windownew2,fl_sleep,fl_slider,fl_slider_hor_fill,fl_slider_hor_nice,fl_slider_hor_slider," & _
  "fl_slider_type,fl_slider_vert,fl_slider_vert_fill,fl_slider_vert_nice,fl_slidergetslider,fl_slidergetslidersize,fl_sliderhandle," & _
  "fl_slidernew,fl_slidernew2,fl_sliderscrollvalue,fl_socket,fl_solid,fl_sort_ascending,fl_sort_descending,fl_sortorder,fl_spinner," & _
  "fl_spinnergetcolor,fl_spinnergetformat,fl_spinnergetmaximum,fl_spinnergetminimum,fl_spinnergetstep,fl_spinnergettextcolor," & _
  "fl_spinnergettextfont,fl_spinnergettextsize,fl_spinnergettype,fl_spinnergetvalue,fl_spinnerhandle,fl_spinnernew,fl_stat," & _
  "fl_stop,fl_string,fl_submenu,fl_submenu_pointer,fl_surface_device,fl_surface_deviceclassname,fl_surface_devicegetdriver," & _
  "fl_surface_devicesurface,fl_symbol,fl_system,fl_scrollscrollto,",search)
  
  case asc("t") : return instr(",fl_tab_key,fl_tabbegin,fl_tabend,fl_table,fl_table_row,fl_table_rowex,fl_table_rowexfindcell," & _
  "fl_table_rowexhandlebase,fl_table_rowexnew,fl_table_rowgetrows,fl_table_rowgettype,fl_table_rownew,fl_table_rowrowselected," & _
  "fl_table_rowselectrow,fl_tablearray,fl_tablecallbackcol,fl_tablecallbackcontext,fl_tablecallbackrow,fl_tablechild," & _
  "fl_tablechildren,fl_tablecontext,fl_tableex,fl_tableexfindcell,fl_tableexhandlebase,fl_tableexnew,fl_tablefind," & _
  "fl_tablegetcolheader,fl_tablegetcolheadercolor,fl_tablegetcolheaderheight,fl_tablegetcolposition,fl_tablegetcolresize," & _
  "fl_tablegetcolresizemin,fl_tablegetcols,fl_tablegetcolwidth,fl_tablegetrowheader,fl_tablegetrowheadercolor," & _
  "fl_tablegetrowheaderwidth,fl_tablegetrowheight,fl_tablegetrowposition,fl_tablegetrowresize,fl_tablegetrowresizemin," & _
  "fl_tablegetrows,fl_tablegettablebox,fl_tablegettoprow,fl_tableinsert,fl_tableisinteractiveresize,fl_tableisselected," & _
  "fl_tablemovecursor,fl_tablenew,fl_tablerowselectmode,fl_tabnew,fl_tabs,fl_tabsend,fl_tabsgetpush,fl_tabsgetvalue," & _
  "fl_tabshandle,fl_tabsnew,fl_tabssetpush,fl_tabssetvalue,fl_tabswhich,fl_testshortcut,fl_text_buffer,fl_text_bufferaddress," & _
  "fl_text_bufferaddress2,fl_text_bufferappendfile,fl_text_bufferbyteat,fl_text_buffercharat,fl_text_buffercountdisplayedcharacters," & _
  "fl_text_buffercountlines,fl_text_bufferfindcharbackward,fl_text_bufferfindcharforward,fl_text_buffergethighlight," & _
  "fl_text_buffergettabdistance,fl_text_buffergettext,fl_text_bufferhighlightposition,fl_text_bufferhighlightselection," & _
  "fl_text_bufferhighlighttext,fl_text_bufferinsertfile,fl_text_bufferlength,fl_text_bufferlineend,fl_text_bufferlinestart," & _
  "fl_text_bufferlinetext,fl_text_bufferloadfile,fl_text_buffernew,fl_text_buffernextchar,fl_text_buffernextcharclipped," & _
  "fl_text_bufferoutputfile,fl_text_bufferprevchar,fl_text_bufferprevcharclipped,fl_text_bufferprimaryselection," & _
  "fl_text_bufferprimaryselection2,fl_text_bufferrewindlines,fl_text_buffersavefile,fl_text_buffersearchbackward," & _
  "fl_text_buffersearchforward,fl_text_buffersecondaryselected,fl_text_buffersecondaryselection,fl_text_bufferaddmodifycallback," & _
  "fl_text_buffersecondaryselectionposition,fl_text_buffersecondaryselectiontext,fl_text_bufferselected," & _
  "fl_text_bufferselectionposition,fl_text_bufferselectiontext,fl_text_bufferskipdisplayedcharacters,fl_text_bufferskiplines," & _
  "fl_text_buffertextrange,fl_text_bufferundo,fl_text_bufferutf8align,fl_text_bufferwordend,fl_text_bufferwordstart,fl_text_display," & _
  "fl_text_display_cursor_shape,fl_text_display_wrap_mode,fl_text_displaycoltox,fl_text_displaycountlines,fl_text_displaygetbuffer," & _
  "fl_text_displaygetcursorcolor,fl_text_displaygetinsertposition,fl_text_displaygetlinenumberalign," & _
  "fl_text_displaygetlinenumberbgcolor,fl_text_displaygetlinenumberfgcolor,fl_text_displaygetlinenumberfont," & _
  "fl_text_displaygetlinenumberformat,fl_text_displaygetlinenumbersize,fl_text_displaygetlinenumberwidth," & _
  "fl_text_displaygetscrollbaralign,fl_text_displaygetscrollbarwidth,fl_text_displaygetshortcut,fl_text_displaygettextcolor," & _
  "fl_text_displaygettextfont,fl_text_displaygettextsize,fl_text_displayhandle,fl_text_displayinselection,fl_text_displaylineend," & _
  "fl_text_displaylinestart,fl_text_displaymovedown,fl_text_displaymoveleft,fl_text_displaymoveright,fl_text_displaymoveup," & _
  "fl_text_displaynew,fl_text_displaypositionstyle,fl_text_displaypositiontoxy,fl_text_displayrewindlines," & _
  "fl_text_displayskiplines,fl_text_displaywordend,fl_text_displaywordstart,fl_text_displaywrappedcolumn," & _
  "fl_text_displaywrappedrow,fl_text_displayxtocol,fl_text_editor,fl_text_editorboundkeyfunction,fl_text_displayredisplayrange," & _
  "fl_text_editorboundkeyfunction2,fl_text_editorgetinsertmode,fl_text_editorhandle,fl_text_editornew," & _
  "fl_text_modify_cb,fl_text_predelete_cb,fl_text_selection,fl_text_selectionend,fl_text_selectiongetselected," & _
  "fl_text_selectionincludes,fl_text_selectionposition,fl_text_selectionstart,fl_text_xxx,fl_thin_down_box," & _
  "fl_thin_down_frame,fl_thin_up_box,fl_thin_up_frame,fl_threadmessage,fl_tile,fl_tilebegin,fl_tiled_image," & _
  "fl_tiled_imagecopy,fl_tiled_imagecopy2,fl_tiled_imageimage,fl_tiled_imagenew,fl_tileend,fl_tilehandle," & _
  "fl_tilenew,fl_timeout_handler,fl_times,fl_times_bold,fl_times_bold_italic,fl_times_italic,fl_toggle_button," & _
  "fl_toggle_buttonnew,fl_tolower,fl_tooltipgetcolor,fl_tooltipgetcurrentwidget,fl_tooltipgetdelay," & _
  "fl_tooltipgetenabled,fl_tooltipgetfont,fl_tooltipgetfontsize,fl_tooltipgethoverdelay,fl_tooltipgetmarginheight," & _
  "fl_tooltipgetmarginwidth,fl_tooltipgettextcolor,fl_tooltipgetwrapwidth,fl_top,fl_toupper,fl_tree,fl_tree_connector," & _
  "fl_tree_connector_dotted,fl_tree_connector_none,fl_tree_connector_solid,fl_tree_item,fl_tree_item_array," & _
  "fl_tree_item_draw_callback,fl_tree_item_draw_default,fl_tree_item_draw_label_and_widget,fl_tree_item_draw_mode," & _
  "fl_tree_item_flags,fl_tree_item_height_from_widget,fl_tree_item_reselect_mode,fl_tree_itemadd,fl_tree_itemadd2," & _
  "fl_tree_itemadditem,fl_tree_itemadditem2,fl_tree_itemdeparent,fl_tree_itemdepth,fl_tree_itemdrawitemcontent," & _
  "fl_tree_itemfindchildbyitem,fl_tree_itemfindchildbyname,fl_tree_itemfindchilditem,fl_tree_itemfindchilditembyname," & _
  "fl_tree_itemfindconstchilditem,fl_tree_itemfindconstchilditembyname,fl_tree_itemfindconstitem,fl_tree_itemfinditem," & _
  "fl_tree_itemgetchild,fl_tree_itemgetchildren,fl_tree_itemgetconstchild,fl_tree_itemgetconstparent,fl_tree_itemgeth," & _
  "fl_tree_itemgetlabel,fl_tree_itemgetlabelbgcolor,fl_tree_itemgetlabelcolor,fl_tree_itemgetlabelfgcolor," & _
  "fl_tree_itemgetlabelh,fl_tree_itemgetlabelsize,fl_tree_itemgetlabelw,fl_tree_itemgetlabelx,fl_tree_itemgetlabely," & _
  "fl_tree_itemgetparent,fl_tree_itemgetprefs,fl_tree_itemgettree,fl_tree_itemgetuserdata,fl_tree_itemgetw," & _
  "fl_tree_itemgetwidget,fl_tree_itemgetx,fl_tree_itemgety,fl_tree_itemhaschildren,fl_tree_iteminsert," & _
  "fl_tree_iteminsertabove,fl_tree_itemisclose,fl_tree_itemisopen,fl_tree_itemlabelfont,fl_tree_itemmove," & _
  "fl_tree_itemmoveabove,fl_tree_itemmovebelow,fl_tree_itemmoveinto,fl_tree_itemmoveitem,fl_tree_itemnew," & _
  "fl_tree_itemnextdisplayed,fl_tree_itemnextsibling,fl_tree_itemprev,fl_tree_itemprevdisplayed," & _
  "fl_tree_itemprevsibling,fl_tree_itemremovechild,fl_tree_itemremovechildsetlabel,fl_tree_itemreparent," & _
  "fl_tree_itemreplace,fl_tree_itemreplacechild,fl_tree_itemswapchildren,fl_tree_prefs,fl_tree_reason," & _
  "fl_tree_reason_closed,fl_tree_reason_deselected,fl_tree_reason_dragged,fl_tree_reason_none,fl_tree_reason_opened," & _
  "fl_tree_reason_reselected,fl_tree_reason_selected,fl_tree_select,fl_tree_select_multi,fl_tree_select_none," & _
  "fl_tree_select_single,fl_tree_select_single_draggable,fl_tree_selectable_always,fl_tree_selectable_once,fl_tree_sort," & _
  "fl_tree_sort_ascending,fl_tree_sort_descending,fl_tree_sort_none,",search) 
  
  case asc("u") : return instr(",fl_ucs_to_utf16,fl_unlink,fl_up,fl_up_box,fl_up_frame,fl_utf_nb_char,fl_utf_strcasecmp," & _
  "fl_utf_strncasecmp,fl_utf_tolower,fl_utf_toupper,fl_utf2mbcs,fl_utf8back,fl_utf8bytes,fl_utf8decode,fl_utf8encode," & _
  "fl_utf8from_mb,fl_utf8froma,fl_utf8fromwc,fl_utf8fwd,fl_utf8len,fl_utf8len1,fl_utf8locale,fl_utf8test," & _
  "fl_utf8to_mb,fl_utf8toa,fl_utf8toutf16,fl_utf8towc,",search)
  
  case asc("v") : return instr(",fl_valuator,fl_valuator_horizontal,fl_valuator_type,fl_valuator_vertical,fl_valuatorclamp," & _
  "fl_valuatorformat,fl_valuatorgetmaximum,fl_valuatorgetminimum,fl_valuatorgetstep,fl_valuatorgetvalue,fl_valuatorincrement," & _
  "fl_valuatorround,fl_valuatorsetvalue,fl_value_input,fl_value_inputgetcursorcolor,fl_value_inputgetshortcut," & _
  "fl_value_inputgetsoft,fl_value_inputgettextcolor,fl_value_inputgettextfont,fl_value_inputgettextsize," & _
  "fl_value_inputhandle,fl_value_inputnew,fl_value_output,fl_value_outputgetsoft,fl_value_outputgettextcolor," & _
  "fl_value_outputgettextfont,fl_value_outputgettextsize,fl_value_outputhandle,fl_value_outputnew,fl_value_slider," & _
  "fl_value_slidergettextcolor,fl_value_slidergettextfont,fl_value_slidergettextsize,fl_value_sliderhandle," & _
  "fl_value_slidernew,fl_version,fl_visual,fl_volume_down,fl_volume_mute,fl_volume_up,",search) 
  
  case asc("w") : return instr(",fl_wait,fl_wait2,fl_wcwidth,fl_when,fl_when_changed,fl_when_enter_key," & _
  "fl_when_enter_key_always,fl_when_enter_key_changed,fl_when_never,fl_when_not_changed,fl_when_release," & _
  "fl_when_release_always,fl_white,fl_widget,fl_widget_tracker,fl_widget_trackerdeleted,fl_widget_trackerexists," & _
  "fl_widget_trackernew,fl_widget_trackerwidget,fl_widget_cast,fl_widgetactive,fl_widgetactiver,fl_widgetasgroup," & _
  "fl_widgetaswindow,fl_widgetchanged,fl_widgetcontains,fl_widgetdamageresize,fl_widgetex,fl_widgetexhandlebase," & _
  "fl_widgetexnew,fl_widgetgetalign,fl_widgetgetargument,fl_widgetgetbox,fl_widgetgetcallback,fl_widgetgetcolor," & _
  "fl_widgetgetcolor2,fl_widgetgetdamage,fl_widgetgetdeimage,fl_widgetgeth,fl_widgetgetimage,fl_widgetgetimage2," & _
  "fl_widgetgetlabel,fl_widgetgetlabelcolor,fl_widgetgetlabelfont,fl_widgetgetlabelsize,fl_widgetgetlabeltype," & _
  "fl_widgetgetparent,fl_widgetgetselectioncolor,fl_widgetgettooltip,fl_widgetgettype,fl_widgetgetuserdata," & _
  "fl_widgetgetw,fl_widgetgetwhen,fl_widgetgetx,fl_widgetgety,fl_widgethandle,fl_widgetinside," & _
  "fl_widgetlabelshortcut,fl_widgetoutput,fl_widgets,fl_widgetsetbox,fl_widgettakefocus,fl_widgettakesevents," & _
  "fl_widgettestshortcut,fl_widgettestshortcut2,fl_widgettopwindow,fl_widgettopwindowoffset,fl_widgetvisible," & _
  "fl_widgetvisibler,fl_widgetwindow,fl_window,fl_windowcurrent,fl_windowdecorated_h,fl_windowdecorated_w," & _
  "fl_windowex,fl_windowexhandlebase,fl_windowexnew,fl_windowexnew2,fl_windowfullscreenactive,fl_windowgetborder," & _
  "fl_windowgeticonlabel,fl_windowgetlabel,fl_windowgetmenuwindow,fl_windowgetmodal,fl_windowgetnonmodal," & _
  "fl_windowgetoverride,fl_windowgettooltipwindow,fl_windowgetxclass,fl_windowhandle,fl_windownew,fl_windownew2," & _
  "fl_windowresizable,fl_windowresizeable,fl_windowsetresizable,fl_windowsetresizeable,fl_windowshown," & _
  "fl_windowxroot,fl_windowyroot,fl_wizard,fl_wizardbegin,fl_wizardend,fl_wizardgetvalue,fl_wizardnew," & _
  "fl_wizardpagebegin,fl_wizardpageend,fl_wizardpagenew,fl_write,fl_widgetposition,fl_windowcopylabel," & _
  "fl_widgetsetcallbackarg,fl_widgetsetlabel,fl_windowhide,fl_widgetsetalign,",search)
  
  case asc("x") : return instr(",fl_xbm_image,fl_xbm_imagenew,fl_xid,fl_xpm_image,fl_xpm_imagenew,",search)
  
  case asc("y") : return instr(",fl_yellow,",search)
  
  case asc("z") : return instr(",fl_zapf_dingbats,",search)
  
  end select
  return 0
end function

' a litle bit syntax highlighting
sub Highlight(byval Text as const zstring ptr,byval Style as zstring ptr,byval length as long)
  #ifdef __FB_DEBUG__
  if Text=0 then flMessageBox("ModifyCb","Text=0")
  if Style=0 then flMessageBox("ModifyCb","Style=0")
  if length<1 then flMessageBox("ModifyCb","length<1")
  #endif
  #define FILLSTYLE(_style_) Style[e]=_style_:e+=1:length-=1:c=Text[e]
  #define RANGESTYLE(_style_) while s<e:Style[s]=_style_:s+=1:wend
  dim as long s,e
  dim as string  w
  print "Highlight " & length
  dim as ubyte   c = Text[e]:length-=1
  while length>0
    ' white chars ?
    while IsWhite(c) andalso length>0
      FILLSTYLE(STYLE_PLAIN)
    wend

    ' single line comment ?
    if c=asc("'") andalso length>0 then
      FILLSTYLE(STYLE_COMMENT)
      while c<>&H0A andalso length>0
        FILLSTYLE(STYLE_COMMENT)
      wend
      if c=&H0D then FILLSTYLE(STYLE_COMMENT)
    end if

    ' multi line comment ?
    if c=asc("/") andalso length>0 then
      if Text[e+1]=asc("'") then
        FILLSTYLE(STYLE_COMMENT): FILLSTYLE(STYLE_COMMENT)
        while c<>asc("'") andalso Text[e]<>asc("/") andalso length>0
          FILLSTYLE(STYLE_COMMENT)
        wend
        FILLSTYLE(STYLE_COMMENT):FILLSTYLE(STYLE_COMMENT)
      end if
    end if

    ' string ?
    if c=34 then
      FILLSTYLE(STYLE_STRING)
      while c<>34 andalso c<>&H0A andalso length>0
        FILLSTYLE(STYLE_STRING)
      wend
      if c=34 then FILLSTYLE(STYLE_STRING)
    end if


    ' string ?
    if c=34 Then
      dim As Long cpt
      FILLSTYLE(STYLE_STRING)
      cpt=1
      while cpt andalso c<>&H0A andalso length>0
        if c=34 then
          FILLSTYLE(STYLE_STRING)
          cpt=1-cpt
          if c=34 then cpt=1-cpt:FILLSTYLE(STYLE_STRING)
        else
          FILLSTYLE(STYLE_STRING)
        end if
      wend
    end if

    ' dec number ?
    if IsNumber(c) then
      FILLSTYLE(STYLE_NUMBER)
      while IsNumber(c) andalso length>0
        FILLSTYLE(STYLE_NUMBER)
      wend
    end if

    ' a part of a float number ? (no E notation)
    if c=asc(".") then
      FILLSTYLE(STYLE_NUMBER)
      while IsNumber(c) andalso length>0
        FILLSTYLE(STYLE_NUMBER)
      wend
    end if

    ' &H &O &B
    if c=asc("&") andalso length>2 then
      if Text[e+1]=asc("h") or Text[e+1]=asc("H") then
        FILLSTYLE(STYLE_NUMBER) : FILLSTYLE(STYLE_NUMBER)
        while IsHex(c) andalso length>0
          FILLSTYLE(STYLE_NUMBER)
        wend
      elseif Text[e+1]=asc("o") or Text[e+1]=asc("O") then
        FILLSTYLE(STYLE_NUMBER) : FILLSTYLE(STYLE_NUMBER)
        while IsOct(c) andalso length>0
          FILLSTYLE(STYLE_NUMBER)
        wend
      elseif Text[e+1]=asc("b") or Text[e+1]=asc("B") then
        FILLSTYLE(STYLE_NUMBER) : FILLSTYLE(STYLE_NUMBER)
        while IsBin(c) andalso length>0
          FILLSTYLE(STYLE_NUMBER)
        wend 
      end if
    end if

    ' get a word
    if c=asc("#") or IsAlpha(c) then
      s=e : w=""
      while c=asc("#") or IsAlphaNum(c) andalso length>0
        w &= chr(c) : e+=1 : length-=1 : c=Text[e]
      wend
      'print "|" & w & "|"
      if IsDatatype(w) then
        RANGESTYLE(STYLE_DATATYPE)
      elseif IsKeyword(w) then
        RANGESTYLE(STYLE_KEYWORD)
      elseif IsPreproc(w) then
        RANGESTYLE(STYLE_PREPROC)
      elseif IsUserlib(w) then
        RANGESTYLE(STYLE_USERLIB)
      else
        RANGESTYLE(STYLE_PLAIN)
      end if

    elseif IsOperator(c) then
      FILLSTYLE(STYLE_OTHER)
    elseif IsDelimiter(c) then
      FILLSTYLE(STYLE_OTHER)
    else
      FILLSTYLE(STYLE_PLAIN)
    end if
  wend
  #undef FILLSTYLE
  #undef RANGESTYLE
end sub

sub ModifyCb cdecl (byval p as long,byval nInserted as long,byval nDeleted as long, _
                    byval nRestyled as long,byval deletedText as const zstring ptr,byval pUserdata as any ptr)
  
  dim as zstring ptr Text,Style
  dim as long e,s=p
  dim as Fl_Text_Editor ptr Editor      = pUserdata
  dim as Fl_Text_Buffer ptr TextBuffer  = Fl_Text_DisplayGetBuffer(Editor)
  dim as Fl_Text_Buffer ptr StyleBuffer = Fl_WidgetGetUserData(Editor)
  
  #ifdef __FB_DEBUG__
  if puserdata=0 then flMessageBox("ModifyCb","puserdata=0")
  if TextBuffer=0 then flMessageBox("ModifyCb","TextBuffer=0")
  if StyleBuffer=0 then flMessageBox("ModifyCb","StyleBuffer=0")
  #endif
  
  print "ModifyCb " & p,nInserted,nDeleted,nRestyled
  if nInserted=0 andalso nDeleted=0 then 
    Fl_Text_BufferUnselect StyleBuffer
    return
  end if

  if (nInserted > 0) then
    e = s + nInserted
    Style = malloc(nInserted + 1)
    memset(Style, STYLE_PLAIN, nInserted)
    Style[nInserted] = 0
    Fl_Text_BufferReplace(StyleBuffer,s,e,Style)
    free Style
  end if
  
  if (nDeleted>0) then
    e = s + nDeleted
    Fl_Text_BufferRemove(StyleBuffer,s,e)
  end if
  Fl_Text_BufferSelect(StyleBuffer,s,e)

  s = Fl_Text_BufferLineStart(TextBuffer,s)
  e = Fl_Text_BufferLength(TextBuffer)
  'e = Fl_Text_BufferLineEnd(TextBuffer,e)

  Text  = Fl_Text_BufferTextRange(TextBuffer ,s,e)
  Style = Fl_Text_BufferTextRange(StyleBuffer,s,e)
  Highlight(Text,Style,e-s)
  Fl_Text_BufferReplace(StyleBuffer,s,e,Style)
  Fl_Text_DisplayRedisplayRange(Editor,s,e)
  Fl_Free Text
  Fl_Free Style
end sub

'
' main
'
var win = Fl_WindowNew(Fl_GetW()*0.75,Fl_GetH()*0.75, "Syntax Highlighter")
var edt = Fl_Text_EditorNew(5,5,Fl_WidgetGetW(win)-10,Fl_WidgetGetH(win)-10)
var TextBuffer  = Fl_Text_BufferNew()
var StyleBuffer = Fl_Text_BufferNew()
Fl_WidgetSetUserdata(edt,StyleBuffer)

Fl_Text_DisplaySetLinenumberWidth(edt,6*8) '0 = line numbers off
Fl_Text_DisplaySetBuffer(edt,TextBuffer)
Fl_Text_DisplayHighlightData(edt,StyleBuffer,@StyleTable(0),ubound(StyleTable)+1)
Fl_Text_BufferAddModifyCallback(TextBuffer,@ModifyCB,edt)
if Fl_Text_BufferLoadFile(TextBuffer,"syntax_highlighter.bas")<>0 then
  Fl_Text_BufferSetText(TextBuffer,!"print \"type your stuff\"")
end if
Fl_GroupSetResizable(win,edt)
Fl_WindowShow(win)
Fl_Run
But i still find some missing here and there, and this will not end soon, i think.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK-C-1.3.3 for FreeBASIC

Post by D.J.Peters »

Looks you made some work based on a simple test for "Style_Table_Entry" :-)

In a real application I would put keywords, per-processor, user library commands etc in external files (never hard coded in the exe)

It was only a test how to color text with a second buffer.

For real time syntax highlighting I would read all stuff from files and build a binary tree.

After every key press the binary tree "knows", are the last and the new typed letter a part of an keyword and if so return the right color.

bla bla bla :-)

However I hope you have fun not only work with it.

Joshy
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

That's the programming fever. :-)
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

For the colors these from geany look perfect. For fltk dark green would be good.
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

D.J.Peters wrote:In a real application
But what is a real application? When i asked you to show complete progams with fltk for fb, you gave me a oop template, means i should program with constructors and destructors, while i haven't seen this in most of your own programs. Same MrSwiss. He almost always programs procedurally. And now you both want to force me to program in oop to avoid the "hell of global variables". While over 95 % of all FreeBASIC programs are procedural, you both want me to do "real applications" with oop...

<going to base room to rofl>
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK-C-1.3.3 for FreeBASIC

Post by D.J.Peters »

You can program as you like I do it also every day :-)

I mean with "In a real application" a complete IDE
not a modification of my C++ wrapper test like "Fl_TextEditor03.bas"

By the way if you hard code the words for syntax highlighting in the executable binary
how should a user of your editor add more keywords ?

Or if I say I would build a binary tree that doesn't mean you have to do it the same way.

That's all I meant, don't be worry, life is too short ;-)

Joshy
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Post by Knatterton »

FastLighter is not meant as a big IDE for dozens of languages like Geany, Codeblocks and others. It is only for FB and Fltk and maybe a few additional libraries.
D.J.Peters wrote:By the way if you hard code the words for syntax highlighting in the executable binary
how should a user of your editor add more keywords ?
Because FastLighter can load it's own code and compile itself users can add and delete keywords directly in the code and recompile. :-)
Post Reply