Page 3 of 6

Posted: Thu Apr 24, 2008 11:25 pm
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


Posted: Fri Apr 25, 2008 8:12 am
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

Posted: Fri Apr 25, 2008 8:54 am
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.

Posted: Fri Apr 25, 2008 10:16 am
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.

Posted: Fri Apr 25, 2008 10:22 am
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?

Posted: Fri Apr 25, 2008 10:39 am
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. :)

Posted: Fri Apr 25, 2008 12:42 pm
by hallodri
My mistake, forget a simple flag

Please download again.
http://www.realsource.de/downloads/doc_ ... editgadget

Posted: Fri Apr 25, 2008 1:01 pm
by srod
That's fixed it. Excellent! :)

Thanks.

Posted: Fri Apr 25, 2008 1:16 pm
by thefool
just noticed this nice work now, defiently something i'll have a look at. Thanks!

Posted: Fri Apr 25, 2008 2:33 pm
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?

Posted: Fri Apr 25, 2008 2:45 pm
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.

Posted: Fri Apr 25, 2008 2:49 pm
by srod
No unicode.... uhm, that limits it's use somewhat. That is a shame.

Posted: Fri Apr 25, 2008 2:54 pm
by ts-soft
How can i test the unicode or utf-8 support? :oops:

Posted: Fri Apr 25, 2008 3:39 pm
by srod
Try pasting some unicode charcaters into it! :)

Is the original RAEdit source available by any chance?

Posted: Fri Apr 25, 2008 3:43 pm
by hallodri