Jump to content

Custom text editor, take highlight text


 Share

Recommended Posts

hello,

need some help for a small text editor

My job system need to stay alway connected (lan, internet) to works.

So i script a small text editor to allow my user to work offline and then send to system.

It does simple task, count chars, save to disk, send to mail, etc.

Now i need to add a simple code menagement. Text effect as BOLD, italic, underline,

are based on open/close tag, so i think to intercept highlight text, add my special codes,

ruturn modified text to editor/user.

Exist any function that i can use ?

thank you for any help,

m.

Link to comment
Share on other sites

thank you for reply FireFox,

now searching for rich edit control

Read about your FTP Easy-up on your signature, but download link is dead...

where i can find this script ?

thank you again for help,

m.

Edited by myspacee
Link to comment
Share on other sites

Hello,

nice reading !

first try:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>

#include <GuiRichEdit.au3>

;////////////////////////////////////////////////////////////////////
;//
;////////////////////////////////////////////////////////////////////
Global $oMyError, $hGui, $Msg, $btnNext, $iStep = 0, $lblMsg, $hRichEdit, $aPos
Local $myedit, $msg

Local $hGui, $hRichEdit, $iMsg
$hGui = GUICreate("Example", 805, 705)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 15, 5, 795, 595, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_AppendText($hRichEdit, @CR & "meat is better than fish")

$Button1 = GUICtrlCreateButton("CONTA !", 105, 610, 100, 75, 0)

GUISetState()


While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
$question = MsgBox(4, @ScriptName, "Quit, are you sure ?")
if $question = 6 then
_GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
GUIDelete()  ; is OK too
Exit
EndIf
Case $Button1
Report("Find cur pos")
_GUICtrlRichEdit_GotoCharPos($hRichEdit, $aPos[0])
_GUICtrlRichEdit_InsertText($hRichEdit, "<")

_GUICtrlRichEdit_GotoCharPos($hRichEdit, $aPos[1])
_GUICtrlRichEdit_InsertText($hRichEdit, ">")

ConsoleWrite($aPos[0] & " - " & $aPos[1] & @CRLF)

EndSwitch
sleep(10)
WEnd

GUIDelete()


Func Report($sMsg)
$aPos = _GUICtrlRichEdit_GetSel($hRichEdit)
ControlFocus($hRichEdit, "", "")
EndFunc

works as i imagine but there is a 'bug' when select text from GUI left side.

(Try to select word 'meat')

Can add any check to correct this issue ?

thank you,

m.

Link to comment
Share on other sites

works as i imagine but there is a 'bug' when select text from GUI left side.

You need to insert > after the highlight, so add a +1 to the second pos.

...

_GUICtrlRichEdit_GotoCharPos($hRichEdit, $aPos[1] +1)
_GUICtrlRichEdit_InsertText($hRichEdit, ">")
...

Br, FireFox.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...