RaEditGadget Userlib

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Here the changed source of the preview:

Code: Select all

XIncludeFile "raedit.pb"

EnableExplicit

Enumeration ; windows
  #frmMain
  ; ...
EndEnumeration

Enumeration ; gadgets
  #RaEdit
  ; ...
EndEnumeration

Enumeration ; menu / toolbar
  #mnuMain
  #mnuFileNew
  ; ...
EndEnumeration

Enumeration ; font
  #fntCourier
EndEnumeration

Procedure.s GetExePath()
  Protected ExePath.s = GetPathPart(ProgramFilename())
  If LCase(ExePath) = LCase(GetTemporaryDirectory()) : ExePath = GetCurrentDirectory() : EndIf
  ProcedureReturn ExePath
EndProcedure

#WINFLAGS = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget

Define.s Text = "", tmpText
Define.l Format

If OpenWindow(#frmMain, #PB_Ignore, #PB_Ignore, 640, 480, "RAEdit Example",  #WINFLAGS)

  SmartWindowRefresh(#frmMain, #True)
  AddKeyboardShortcut(#frmMain, #PB_Shortcut_Control | #PB_Shortcut_N, #mnuFileNew)

  If CreateMenu(#mnuMain, WindowID(#frmMain))
    MenuTitle("File")
    MenuItem(#mnuFileNew, "New" + #TAB$ + "Ctrl+N")
    ; ...
  EndIf

  If CreateToolBar(#mnuMain, WindowID(#frmMain))
    ToolBarStandardButton(#mnuFileNew, #PB_ToolBarIcon_New)
    ; ...
  EndIf

  If CreateGadgetList(WindowID(#frmMain))
    RaEditGadget(#RaEdit, 0, ToolBarHeight(#mnuMain), 0, 0)
    
    SetGadgetColor(#RaEdit, #RaEdit_BackColor, #White)
    SetGadgetAttribute(#RaEdit, #RaEdit_HilightLine, #True)
    SetGadgetAttribute(#RaEdit, #RaEdit_LineNumberBar, #True)
    SetGadgetAttribute(#RaEdit, #RaEdit_NoLockButton, #True)
    
    RaEditAddDefBlock(#RaEdit,"enumeration", "endenumeration", #BD_INCLUDELAST | #BD_DIVIDERLINE)
    RaEditAddDefBlock(#RaEdit,"datasection", "enddatasection", #BD_INCLUDELAST | #BD_DIVIDERLINE)
    SendMessage_(GadgetID(#RaEdit), #REM_SETCHARTAB, '.', #CT_OPER)
    RaEditAddDefBlock(#RaEdit,"procedure", "endprocedure", #BD_INCLUDELAST | #BD_DIVIDERLINE)
    RaEditAddDefBlock(#RaEdit,"if !endif", "endif", #BD_INCLUDELAST)
    RaEditAddDefBlock(#RaEdit,"while !wend", "wend", #BD_INCLUDELAST)
    RaEditAddDefBlock(#RaEdit,"repeat !until", "until", #BD_INCLUDELAST)
    RaEditAddDefBlock(#RaEdit,"repeat", "forever", #BD_INCLUDELAST)
    RaEditAddDefBlock(#RaEdit,"select", "endselect", #BD_INCLUDELAST)
    SendMessage_(GadgetID(#RaEdit), #REM_SETCHARTAB, '#', #CT_NONE)
    
    RaEditSetHiliteWords(#RaEdit, $006500, "sendmessage_")
    
    Restore KeyWordRed
    Text = ""
    Repeat
      Read tmpText
      If tmpText
        Text + tmpText + Space(1)
      EndIf
    Until tmpText = ""
    RaEditSetHiliteWords(0, #Red, Text)
    
    Restore KeyWordBlue
    Text = ""
    Repeat
      Read tmpText
      If tmpText
        Text + tmpText + Space(1)
      EndIf
    Until tmpText = ""
    RaEditSetHiliteWords(0, #Blue, Text)
    
    SetGadgetFont(#RaEdit, LoadFont(#fntCourier, "Courier New", 10))

    Text = "" : Format.l = #PB_Ascii
    If ReadFile(0, GetExePath() + "example2.pb")
      Format = ReadStringFormat(0)
      While Not Eof(0)
        Text + ReadString(0, Format) + #CRLF$
      Wend
      CloseFile(0)
      SetGadgetText(#RaEdit, Text)
    EndIf


    ; ...
  EndIf

  Repeat

    Select WaitWindowEvent()

      Case #PB_Event_CloseWindow
        Break

      Case #PB_Event_SizeWindow
        ResizeGadget(#RaEdit, #PB_Ignore, #PB_Ignore, WindowWidth(#frmMain), WindowHeight(#frmMain) - MenuHeight() - ToolBarHeight(#mnuMain))
        SetActiveGadget(#RaEdit)
      Case #PB_Event_Menu
        Select EventMenu()

          Case #mnuFileNew
            SetGadgetText(#RaEdit, "")

        EndSelect
    EndSelect

  ForEver

EndIf

DataSection
KeyWordRed:
  Data.s "enableexplicit"
  Data.s "enumeration"
  Data.s "endenumeration"
  Data.s "procedure"
  Data.s "endprocedure"
  Data.s "define"
  Data.s "if"
  Data.s "endif"
  Data.s "read"
  Data.s "restore"
  Data.s "repeat"
  Data.s "until"
  Data.s "forever"
  Data.s "case"
  Data.s "default"
  Data.s "while"
  Data.s "wend"
  Data.s "select"
  Data.s "endselect"
  Data.s "datasection"
  Data.s "enddatasection"
  Data.s "break"
  Data.s "protected"
  Data.s "global"
  Data.s "not"
  Data.s "procedurereturn"
  Data.s ""
KeyWordBlue:
  Data.s "openwindow"
  Data.s "smartwindowrefresh"
  Data.s "addkeyboardshortcut"
  Data.s "createmenu"
  Data.s "menutitle"
  Data.s "menuitem"
  Data.s "createtoolbar"
  Data.s "toolbarstandardbutton"
  Data.s "creategadgetlist"
  Data.s "setgadgetfont"
  Data.s "setgadgettext"
  Data.s "readfile"
  Data.s "readstring"
  Data.s "closefile"
  Data.s "setactivegadget"
  Data.s "readstringformat"
  Data.s "waitwindowevent"
  Data.s "windowevent"
  Data.s "eventmenu"
  Data.s "eventgadget"
  Data.s "resizegadget"
  Data.s "lcase"
  Data.s "ucase"
  Data.s "raeditgadget"
  Data.s "raeditadddefblock"
  Data.s "raeditsendmessage"
  Data.s "getcurrentdirectory"
  Data.s "gettemporarydirectory"
  Data.s "getpathpart"
  Data.s "programfilename"
  Data.s "toolbarheight"
  Data.s "loadfont"
  Data.s "space"
  Data.s "windowwidth"
  Data.s "windowheight"
  Data.s "menuheight"
  Data.s "windowid"
  Data.s "xincludefile"
  Data.s "raeditsethilitewords"
  Data.s ""
EndDataSection

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
liverol
User
User
Posts: 26
Joined: Sat Jul 14, 2007 3:21 am

Post by liverol »

hi there,thanks for the great lib,but i got an error when compiled:

Code: Select all

line 759:Strutrue field not found:Datas. (in file raedit.pb)

error at line  "RAdata*=*Gadget\datas[3];
so,what's wrong??thanks

i'm using pb4.10
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Post by hallodri »

srod wrote:Thanks for that; quite some work there! 8)

With the example though I am unable to affect the #STYLE_NOHSCROLL style either when creating the gadget or through SetGadgetAttribute() etc.
#STYLE_NOHSCROLL is only valid with
#STYLE_NOCOLLAPSE
#STYLE_NOLOCK
#STYLE_NOLINENUMBER

And #STYLE_NOVSCROLL needs
#STYLE_NOSPLITT

Code: Select all

XIncludeFile ("raedit.pb")

hwnd = OpenWindow(0,#PB_Ignore,#PB_Ignore,480,400,"",#WS_OVERLAPPEDWINDOW)
       SmartWindowRefresh(0,#True)
       
       CreateGadgetList(hwnd)
       ws = #STYLE_NOCOLLAPSE | #STYLE_NOLOCK | #STYLE_NOLINENUMBER | #STYLE_NOHSCROLL
       ws | #STYLE_NOSPLITT | #STYLE_NOVSCROLL
       ra = RaEditGadget(0,0,0,400,400,ws,0)

Repeat
  event = WaitWindowEvent()
  
  If event = #PB_Event_SizeWindow
    ResizeGadget(0,#PB_Ignore,#PB_Ignore,WindowWidth(0),WindowHeight(0))
  EndIf 
  
Until event = #PB_Event_CloseWindow
srod wrote:Also, I cannot collapse the Procedure block.
It works here with ascii,unicode, threadsave on vista ,xp and PB 4.2b4.
You change the code ?
liverol wrote:hi there,thanks for the great lib,but i got an error when compiled:

Code: Select all

line 759:Strutrue field not found:Datas. (in file raedit.pb)

error at line  "RAdata*=*Gadget\datas[3];
so,what's wrong??thanks

i'm using pb4.10
*=* ?

please download and test again.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

It works here with ascii,unicode, threadsave on vista ,xp and PB 4.2b4.
You change the code ?
Nope. I've downloaded again. I've tried the test.pb program as well as the original examples which were included with the userlib package - I cannot collapse any group at all. When I try, a divider line appears, and that's it! PB 4.2 beta 4, Win XP pro SP 2.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

srod wrote: Nope. I've downloaded again. I've tried the test.pb program as well as the original examples which were included with the userlib package - I cannot collapse any group at all. When I try, a divider line appears, and that's it! PB 4.2 beta 4, Win XP pro SP 2.
this seems to be unicode bug?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

ts-soft wrote:
srod wrote: Nope. I've downloaded again. I've tried the test.pb program as well as the original examples which were included with the userlib package - I cannot collapse any group at all. When I try, a divider line appears, and that's it! PB 4.2 beta 4, Win XP pro SP 2.
this seems to be unicode bug?
Yes, sorry I didn't even check that! It is indeed a unicode thing -works fine in ascii mode. Any idea how to fix that? With this fixed I will definitely proceed to use this great lib. :)
I may look like a mule, but I'm not a complete ass.
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Post by hallodri »

My mistake, forget a simple flag

Please download again.
http://www.realsource.de/downloads/doc_ ... editgadget
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

That's fixed it. Excellent! :)

Thanks.
I may look like a mule, but I'm not a complete ass.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

just noticed this nice work now, defiently something i'll have a look at. Thanks!
liverol
User
User
Posts: 26
Joined: Sat Jul 14, 2007 3:21 am

Post by liverol »

very nice, this is great, just a question(request)
i wonder if i can use unicode characters in the editor?
i try to input asia unicode char in the editor but some
random ascii chars appeared.any way to fix this?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

liverol wrote:very nice, this is great, just a question(request)
i wonder if i can use unicode characters in the editor?
i try to input asia unicode char in the editor but some
random ascii chars appeared.any way to fix this?
The lib itself doesn't support unicode, the wrapper supports only to works
with unicode-applications.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

No unicode.... uhm, that limits it's use somewhat. That is a shame.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

How can i test the unicode or utf-8 support? :oops:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Try pasting some unicode charcaters into it! :)

Is the original RAEdit source available by any chance?
I may look like a mule, but I'm not a complete ass.
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Post by hallodri »

Post Reply