Jump to content

GUI RichEdit Control Showing Symbols


Recommended Posts

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:

 

#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 by NassauSky
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

 

; 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 by ioa747

I know that I know nothing

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...