Page 3 of 3

Re: Automatic splitting code across lines...

Posted: Sun Sep 30, 2012 4:06 pm
by Danilo
Thanks, works fine. You can set indent level of wrapped lines to match indentation level of original line, plus one more level of indentation if you want.

Code: Select all

Scintilla = Val( GetEnvironmentVariable("PB_TOOL_Scintilla") )

If Scintilla
    SendMessageTimeout_(Scintilla,#SCI_GETWRAPMODE,0,0,#SMTO_ABORTIFHUNG,2000,@result)
    If result = 0
        wrapmode = 1 ; 1 = wrap at word boundary
                     ; 2 = wrap at character boundary (for asian languages without spaces)
    Else
        wrapmode = 0
    EndIf

    ; by DoubleDutch, add visual marker and indent wrapped line
    ; http://www.purebasic.fr/english/viewtopic.php?f=18&t=30385
    ; http://forums.purebasic.com/german/viewtopic.php?f=16&t=25933&start=28
    SendMessageTimeout_(Scintilla, #SCI_SETWRAPVISUALFLAGS, #SC_WRAPVISUALFLAG_START, 0, #SMTO_ABORTIFHUNG,2000,@result)
    SendMessageTimeout_(Scintilla, #SCI_SETWRAPSTARTINDENT, 16, 0, #SMTO_ABORTIFHUNG,2000,@result)                    ; <-- indent amount
    SendMessageTimeout_(Scintilla, #SCI_SETWHITESPACEFORE, #True, RGB($70, $50, $d0), #SMTO_ABORTIFHUNG,2000,@result) ; <-- colour of marker

    #SCI_SETWRAPINDENTMODE = 2472
    #SC_WRAPINDENT_FIXED  = 0 ; Wrapped sublines aligned To left of window plus amount set by SCI_SETWRAPSTARTINDENT
    #SC_WRAPINDENT_SAME   = 1 ; Wrapped sublines are aligned To first subline indent
    #SC_WRAPINDENT_INDENT = 2 ; Wrapped sublines are aligned To first subline indent plus one more level of indentation
    SendMessageTimeout_(Scintilla,#SCI_SETWRAPINDENTMODE, 2, 0, #SMTO_ABORTIFHUNG,2000,@result)                       ; <-- indent mode

    #SC_WRAPVISUALFLAGLOC_DEFAULT       = 0 ; Visual flags drawn near border
    #SC_WRAPVISUALFLAGLOC_END_BY_TEXT   = 1 ; Visual flag at End of subline drawn near text
    #SC_WRAPVISUALFLAGLOC_START_BY_TEXT = 2 ; Visual flag at beginning of subline drawn near text
    SendMessageTimeout_(Scintilla,#SCI_SETWRAPVISUALFLAGSLOCATION, 2, 0, #SMTO_ABORTIFHUNG,2000,@result)              ; <-- marker location

    SendMessageTimeout_(Scintilla,#SCI_SETWRAPMODE,wrapmode,0,#SMTO_ABORTIFHUNG,2000,@result)
EndIf

Re: Automatic splitting code across lines...

Posted: Sun Sep 30, 2012 7:52 pm
by c4s
Thank you Danilo, works great!

Besides your Smart Highlighting, this is now my second must-have IDE tool... 8)

Re: Automatic splitting code across lines...

Posted: Mon Oct 01, 2012 2:12 pm
by c4s
c4s wrote:works great!
Oh sorry, I just noticed that it doesn't work great at all. When enabled as an IDE tool (using "start after source code loaded", with PB5.0b3 on WinXP 32bit) strange things happen:
- Pressing Enter for a new line will create 2 new lines.
- Parts of my source code (maybe every 2kb or so) were replaced with random PureBasic keywords such as FileSize, If, AllocateMemory etc. Unfortunately I'm currently not able to reproduce this behavior.
- Sometimes the special wrap indication character doesn't get colored (stays gray instead of purple).

Any ideas how this can be fixed?

Re: Automatic splitting code across lines...

Posted: Mon Oct 01, 2012 3:31 pm
by DoubleDutch
The calls to enable the line wrap shouldn't do that. It must be something else?

Re: Automatic splitting code across lines...

Posted: Mon Oct 01, 2012 7:01 pm
by Danilo
c4s wrote:Any ideas how this can be fixed?
Try new Scintilla.dll? Maybe another problem with the Beta? Disable all tools for a while?

Re: Automatic splitting code across lines...

Posted: Mon Oct 01, 2012 8:45 pm
by c4s
Hm, I have no other tool installed (except the highlighter which is only triggered via a key shortcut) and Scintilla 3.1.0 should already come with PureBasic 5.0 (see changelog)...

The problem with the doubled new line and randomly inserted keywords is really strange. Maybe some memory error?!

Re: Automatic splitting code across lines...

Posted: Mon Oct 01, 2012 8:53 pm
by ts-soft
c4s wrote:and Scintilla 3.1.0 should already come with PureBasic 5.0 (see changelog)...
should, but is it? I think not :mrgreen:

Re: Automatic splitting code across lines...

Posted: Mon Oct 01, 2012 10:34 pm
by skywalk
Yeah, I had to paste in the latest compiled scintilla dll according to this...
http://www.purebasic.fr/english/viewtop ... 51#p391251

Re:

Posted: Tue Oct 02, 2012 11:48 am
by Danilo
freak (03.01.08 [18:11]) wrote:I can add the option, its no problem.
Thank you freak, would be nice! Maybe for PB 5.00 Final?

What about block insert? Block selection works with Shift+Alt+CursorKeys or Alt+MouseSelection - i can select a block and delete it by pressing backspace.
After deleting the block, the block cursors blink, but Strg/Ctrl+V does not insert text at all block lines... only at the first line of the block.
The same text should be inserted at all block lines. It is used to replace a block selection with other text. Thanks!

Re: Automatic splitting code across lines...

Posted: Sun Aug 30, 2015 10:39 pm
by ostapas
WARNING: This is an experimental editor patch, it may have unpredictable results (you may lose work) !!!
I think, you should remove this warning, no unpredictable results were reported during 7 years :)

Re: Automatic splitting code across lines...

Posted: Wed Sep 02, 2015 11:18 am
by DoubleDutch
:)

I thought they were going to build it in...

Re:

Posted: Tue Dec 05, 2023 1:10 am
by BarryG
freak in 2008 wrote:I can add the option, its no problem.
Bump. :)

Re: Automatic splitting code across lines...

Posted: Tue Dec 05, 2023 8:53 am
by DoubleDutch
Bump, Bump! :)

Re: Automatic splitting code across lines...

Posted: Tue Dec 05, 2023 4:22 pm
by freak

Re: Automatic splitting code across lines...

Posted: Tue Dec 05, 2023 8:16 pm
by idle
freak wrote: Tue Dec 05, 2023 4:22 pm Good news! You can help now: https://github.com/fantaisie-software/purebasic
but its so much easier to ask you to do it. :lol: