Jump to content

Make edit control accept @LF 's


Recommended Posts

what can be used to make the edit control display @LF 's when i paste text with line breaks with @LF 's in to it  (even temporarily)

the control starts of like so  $idInput = GUICtrlCreateEdit("", $iLeft, 35, 720, 310, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))


Edit: Pain in the neck:



Edited by Deye
Link to comment
Share on other sites

Thanks Zedna

I didn't explain the problem properly

the reason i needed the edit control to display all soft breaks as @CRLF 's is that i needed this for both previewing but also copying from the edit control as a source

with what i have tried, nothing will allow copying from the edit display control like it should

for instance going and pasting it as a source into notepad (yields extra line breaks .. when using @CRLF 's  instead)

after all i don't think it will be possible to convert soft breaks to look like @CRLF in the edit control even if using a EditWordBreakProc ( .. not sure :unsure:)

Edited by Deye
Link to comment
Share on other sites

Not sure I get you, but if it's only for denoting LFs visually in the control, you can StringReplace @LF in the string by '¶' & @LF then set the result in the control.

Of course if you want to copy-paste something from there, you'll need to StringReplace ' by '' after copying.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Link to comment
Share on other sites

In the end it was just a tricky matter of figuring out where @LF 's go and @CRLF 's
I guess I didn't have much luck with first attempts so i got bewildered looking for other ways which eventually can get harder to accomplish as we know ..

And suddenly voila:
This will convert lines from the clipboard and back to a $var also displaying correctly the lines to the edit control and allowing copying from the edit control and pasting the lines as they look to another editor

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

$hGUI = GUICreate("Example", 785, 400)
$idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)
$idInput = GUICtrlCreateEdit("", 10, 10, 760, 310, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        Case $idOK
            GUICtrlSetData($idInput, "")

Func _GetTextToVar($sfile= ClipGet())
    If Not ($sfile) Then Return
    Local $str = @CRLF & StringReplace($sfile, "'", "''")
    $str = StringStripCR($str)
    $str = StringRegExpReplace($str, '(.{1,100})', "& '$1' _" & @LF)
    $str = StringRegExpReplace($str, "\_\n{2}\& ", "_" & @CRLF & "& @LF & $1")
    $str = StringStripWS($str, 3)
    $Var = "$Var"
    $str = "Local " & $Var & " = '' _" & @CRLF & StringTrimRight($str, 2)
    $str = StringRegExpReplace($str, "\_\n{3,1000}", " & @LF & @CRLF" & @CRLF & $Var & ' = ')
    $str = StringReplace($str, $Var & " = &", $Var & " &=")
    GUICtrlSetData($idInput, $str)
EndFunc   ;==>_gefTextVar

Thanks guys 

Edited by Deye
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

  • Recently Browsing   0 members

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