NassauSky Posted April 26 Share Posted April 26 (edited) Is there a way to show symbols in the rich edit control. In this case I'd like to create a richedit control that shows tabs and spaces: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> Example() Func Example() Local $hGUI, $btnRemoveTabs, $editBox $hGUI = GUICreate("Remove Tabs", 1000, 800) $editBox = _GUICtrlRichEdit_Create($hGUI,"", 10, 10, 980, 700) _GUICtrlRichEdit_SetFont($editBox, 12) GUICtrlSetData(-1, "") $btnRemoveTabs = GUICtrlCreateButton("Remove Tabs & CRLFs", 400, 730, 200, 30) GUICtrlSetState(-1, $GUI_FOCUS) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btnRemoveTabs Local $sInput = GUICtrlRead($editBox) RemoveTabs($sInput) EndSwitch WEnd GUIDelete() EndFunc Func RemoveTabs($sInput) Local $sOutput $sOutput = StringReplace($sInput, @TAB, "") ClipPut($sOutput) SplashTextOn("Done", "Tabs removed and saved to clipboard!", 300, 50, -1, -1, 3) Sleep(1000) SplashOff() Return $sOutput EndFunc Edited April 26 by NassauSky Link to comment Share on other sites More sharing options...
MattyD Posted April 27 Share Posted April 27 It's probably not a great way of going about things, but as a quick and dirty you could pop this in an adlib! Func UpdateEdit() Local $sNewTxt, $aiSel $aiSel = _GUICtrlRichEdit_GetSel($editBox) $sTxt = _GUICtrlRichEdit_GetText($editBox) $sNewTxt = StringReplace($sTxt, " ", ChrW(0x00B7)) $sNewTxt = StringReplace($sNewTxt, @TAB, ChrW(0x2192)) If $sTxt <> $sNewTxt Then _GUICtrlRichEdit_SetText($editBox, $sNewTxt) _GUICtrlRichEdit_SetSel($editBox, $aiSel[0], $aiSel[1]) EndIf EndFunc NassauSky 1 Link to comment Share on other sites More sharing options...
ioa747 Posted April 27 Share Posted April 27 (edited) expandcollapse popup; https://www.autoitscript.com/forum/topic/211837-gui-richedit-control-showing-symbols/#comment-1533262 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> Global $hGUI, $btnRemoveTabs, $editBox Local $sTxt = "" $sTxt &= "Func Example()" & @CRLF $sTxt &= "" & @CRLF $sTxt &= @TAB & "$hGUI = GUICreate(""Remove Tabs"", 1000, 800)" & @CRLF $sTxt &= "" & @CRLF $sTxt &= @TAB & "$editBox = _GUICtrlRichEdit_Create($hGUI,"""", 10, 10, 980, 700)" & @CRLF $sTxt &= @TAB & @TAB & @TAB & "_GUICtrlRichEdit_SetFont($editBox, 12)" & @CRLF $sTxt &= @TAB & "GUICtrlSetData(-1, """")" & @CRLF $sTxt &= "" & @CRLF $sTxt &= @TAB & "$btnRemoveTabs = GUICtrlCreateButton(""Remove Tabs & CRLFs"", 400, 730, 200, 30)" & @CRLF $sTxt &= @TAB & "GUICtrlSetState(-1, $GUI_FOCUS)" & @CRLF $sTxt &= "" & @CRLF $sTxt &= @TAB & "GUISetState(@SW_SHOW)" & @CRLF $sTxt &= "" & @CRLF $sTxt &= @TAB & "While 1" & @CRLF $sTxt &= @TAB & @TAB & "Switch GUIGetMsg()" & @CRLF $sTxt &= @TAB & @TAB & "Case $GUI_EVENT_CLOSE" & @CRLF $sTxt &= @TAB & @TAB & @TAB & "ExitLoop" & @CRLF $sTxt &= @TAB & @TAB & "Case $btnRemoveTabs" & @CRLF $sTxt &= @TAB & @TAB & @TAB & "Local $sInput = GUICtrlRead($editBox)" & @CRLF $sTxt &= @TAB & @TAB & @TAB & "RemoveTabs($sInput)" & @CRLF $sTxt &= @TAB & @TAB & "EndSwitch" & @CRLF $sTxt &= @TAB & "WEnd" & @CRLF $sTxt &= "" & @CRLF $sTxt &= @TAB & "GUIDelete()" & @CRLF $sTxt &= "EndFunc" & @CRLF Example($sTxt) ;-------------------------------------------------------------------------------------------------------------------------------- Func Example($sTxt) $hGUI = GUICreate("Remove Tabs", 1000, 800) $editBox = _GUICtrlRichEdit_Create($hGUI, $sTxt, 10, 10, 980, 700) _GUICtrlRichEdit_SetFont($editBox, 12) GUICtrlSetData(-1, "") $btnRemoveTabs = GUICtrlCreateButton("Remove Tabs & CRLFs", 400, 730, 200, 30) GUICtrlSetState(-1, $GUI_FOCUS) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btnRemoveTabs Local $sInput = RemoveTabs(_GUICtrlRichEdit_GetText($editBox)) EndSwitch ConformEdit() Sleep(50) WEnd GUIDelete() EndFunc ;==>Example ;-------------------------------------------------------------------------------------------------------------------------------- Func RemoveTabs($sInput) Local $sOutput = $sInput $sOutput = StringReplace($sOutput, "→", "") $sOutput = StringReplace($sOutput, "↭", "") ClipPut($sOutput) SplashTextOn("Done", "Tabs removed and saved to clipboard!", 300, 50, -1, -1, 3) Sleep(1000) SplashOff() Return $sOutput EndFunc ;==>RemoveTabs ;-------------------------------------------------------------------------------------------------------------------------------- Func ConformEdit() Local Static $sCurTxt Local $sNewTxt, $aiSel $aiSel = _GUICtrlRichEdit_GetSel($editBox) $sNewTxt = _GUICtrlRichEdit_GetText($editBox) If $sCurTxt = $sNewTxt Then Return ConsoleWrite("..." & @CRLF) $sNewTxt = StringReplace($sNewTxt, @TAB, "→") $sNewTxt = StringReplace($sNewTxt, " ", "↭") ; ↭ ⇝ ↝ $sCurTxt = $sNewTxt _GUICtrlRichEdit_SetText($editBox, $sCurTxt) _GUICtrlRichEdit_SetSel($editBox, $aiSel[0], $aiSel[1]) EndFunc ;==>ConformEdit ;-------------------------------------------------------------------------------------------------------------------------------- Edited April 27 by ioa747 NassauSky 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now