Page 6 of 6

Posted: Fri Jul 25, 2008 7:53 am
by ts-soft

Code: Select all

WriteStringN(
See the N!

Posted: Fri Aug 08, 2008 12:38 pm
by kawasaki
Hello TS-Soft,

May I ask, is there a way to get the current location of the cursor on the RAEdit Gadget? So Cursor position on the horizontal, and the current line?

And is there a more advisable way of getting the current line content, rather than recieving the Gadget Text, and navigating through all the End of line characters using StringField?


Much Regards,

Mike

Posted: Fri Aug 08, 2008 5:10 pm
by hallodri
Try this :

Code: Select all

Procedure.s GetLineText(gadget,line)
	Protected hwnd.l
	Protected pos.l
	Protected len.l
	Protected buffer.s
	
	If IsGadget(gadget)
		
		hwnd = GadgetID(gadget)
		
		pos = SendMessage_(hwnd,#EM_LINEINDEX,line,0)
	  	 	
		len = SendMessage_(hwnd,#EM_LINELENGTH,pos,0)
		
		buffer = Space(len)
		
		SendMessage_(hwnd,#EM_GETLINE,line,@buffer)
		
	EndIf 
	
	ProcedureReturn buffer	
EndProcedure

Procedure GetCurrentLine(gadget)
	Protected hwnd.l
	Protected line.l
	Protected *red.edit
	
	If IsGadget(gadget)			
		
		hwnd = GadgetID(gadget)
		
		*red = GetWindowLong_(hwnd,0)
		
		If *red  

			line = SendMessage_(hwnd,#EM_LINEFROMCHAR ,*red\edta\cp,0)	  	 	
																	;        ^ *red\edtB\cp for second editcontrol
		EndIf 
		
	EndIf 
	
	ProcedureReturn line	
EndProcedure

Posted: Mon Aug 11, 2008 6:29 pm
by kawasaki
Hello there,

Can I request that font formatting for various keyword catagories be implimented? so for instance if you add a block of keywords with a certain colour, have the oppurtunity to set them to be bold, or italic etc.

Thanks,
Mike

Posted: Thu Apr 23, 2009 7:40 pm
by drgolf
Hello
Help needed !

I execute this exemple, and when the mouse cursor go to the toolbar icon the program freeze.
Any solution ?????

Code: Select all

XIncludeFile ("raedit.pb")

Enumeration ; windows
  #frmMain
  ; ...
EndEnumeration

Enumeration ; gadgets
  #RaEdit
  ; ...
EndEnumeration

Enumeration ; menu / toolbar
  #mnuMain
  #mnuFileNew
  #toolmain
  #toolnew
  ; ...
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",  #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)

  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(#toolMain, WindowID(#frmMain))
    ToolBarStandardButton(#toolNew, #PB_ToolBarIcon_Open)
    ; ...
  EndIf

  ;If CreateGadgetList(WindowID(#frmMain))
    RaEditGadget(#RaEdit, 0, ToolBarHeight(#toolMain), 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.s tmpText
      If tmpText
        Text + tmpText + Space(1)
      EndIf
    Until tmpText = ""
    RaEditSetHiliteWords(0, #Red, Text)
    
    Restore KeyWordBlue
    Text = ""
    Repeat
      Read.s 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
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(#toolMain))
        SetActiveGadget(#RaEdit)
      Case #PB_Event_Menu
        Select EventMenu()

          Case #mnuFileNew
            SetGadgetText(#RaEdit, "")

        EndSelect
      Case #PB_Event_Gadget
        ;Debug RaEditGetCurrentWord(#RaEdit)  
    EndSelect

  ForEver


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

This lib is very good and usefull.