Jump to content
Sign in to follow this  
mrider

Can edit control show visual break with @LF?

Recommended Posts

mrider

Greetings:

I'm unsure if this is possible.  What I'd like to do is have an edit control (created with GUICtrlCreateEdit) do a visual break with @LF instead of the full @CRLF.  Currently, if I put a string inside the control that has only a @LF without @CR, it does not visually break.  The trick is that I'm displaying text from an outside source and I need to use the line breaks as they are.  It works without the visual break, but it's a pain to look at or work wtih.  I'm having to copy the text, paste into SciTE, monkey with what I see, then paste back into my editor.

Is it possible to make the left side look like the right?  (see image and replicator script)

Replicator script:

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

GUICreate("Test Line Feeds", 400, 200)
$no_cr = GUICtrlCreateEdit("", 10, 10, 180, 180, $ES_AUTOVSCROLL + $WS_VSCROLL)
$w_cr  = GUICtrlCreateEdit("", 210, 10, 180, 180, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUISetState(@SW_SHOW)

GUICtrlSetData($no_cr, "First Line" & @LF & "Second line")
GUICtrlSetData($w_cr, "First Line" & @CRLF & "Second line")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd
GUIDelete()

post-4896-0-63814900-1393879201_thumb.pn

Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
Share on other sites
BrewManNH

I believe that an edit control needs a CRLF line ending, so to get around that you could use the following to normalize your line endings.

 

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

GUICreate("Test Line Feeds", 400, 200)
$no_cr = GUICtrlCreateEdit("", 10, 10, 180, 180, $ES_AUTOVSCROLL)
$w_cr  = GUICtrlCreateEdit("", 210, 10, 180, 180, $ES_AUTOVSCROLL)
GUISetState(@SW_SHOW)
$sStringNoCR = "First Line" & @LF  & "Second line"
$sString = StringRegExpReplace($sStringNoCR, "(\r\n|\n)", @CRLF) ; replaces @LF with @CRLF
GUICtrlSetData($no_cr,$sString)
$sStringWCR =  "First Line" & @CRLF & "Second line"
$sString = StringRegExpReplace( $sStringWCR, "(\r\n|\n)", @CRLF) ; replaces @CRLF with @CRLF (in other words, no change made)
GUICtrlSetData($w_cr,$sString)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd
GUIDelete()

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
mrider

That's what I was afraid of.

I'd have to go through a WHOLE bunch more work to normalize the line endings since I'm examining data that is created and used elsewhere.  I'd have to remember the string internally and then restore it before using it, otherwise it would alter the binary signature.  What sucks is that it's actually the inflexibility of the other end that causes this.  The system expects to find precisely the same line endings as was put there originally.  I whipped up a simple tool to examine and monkey with the data, but I have to be careful when dealing with @LF only.

Sigh - it was worth a try.  Thanks!!


How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
Share on other sites
BrewManNH

Well, after you're done putting it into your Edit control, you can always remove the @CR part with StringStripCR before sending it to wherever it needs to go.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
mrider

True, except that there's no guarantee that I need no @CRs at all.  The file is really funky - it's an internal proprietary file format that may contain @LF or @CRLF with no rhyme or reason.  Trying to modify it would not be impossible, but it would be extremely ugly.  My thought about creating a viewer/editor isn't worth the hassle.

Thanks though.

Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
Share on other sites
Melba23

mrider,

Do not be so defeatist! :D

How about splitting the file into lines (regardless of EOL) and then using an editable ListView (controlled by my GUIListViewEx UDF) to adjust the individual lines. You can also store the required EOL code for each line and then you can very easily restore them when reconstituting the file. :)

Can you let me see an example of this wonder file so that I try and work out a suitable framework. :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
mrider

I apologize, didn't realize there was another post in this thread...

 

Can you let me see an example of this wonder file so that I try and work out a suitable framework. :huh:

 

Sorry, no can do - it would be a huge HIPAA violation.  Granted, I could redact the file with a fair amount of work, but it's not worth it considering my solution.

My solution was simple: I switched from AutoIt to Perl with WxWidgets, and I used the Styled Text Control as the editor.  Since it's based on Scintilla, it handles variable line endings just fine.  Granted, it was a bit more work, and granted the compiled program (via the Perl Packer) is quite a bit larger, but it works.

So thanks anyway... :)


How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
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
Sign in to follow this  

×