Automatic splitting code across lines...

Working on new editor enhancements?
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Automatic splitting code across lines...

Post 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
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Automatic splitting code across lines...

Post by c4s »

Thank you Danilo, works great!

Besides your Smart Highlighting, this is now my second must-have IDE tool... 8)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Automatic splitting code across lines...

Post 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?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Automatic splitting code across lines...

Post by DoubleDutch »

The calls to enable the line wrap shouldn't do that. It must be something else?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Automatic splitting code across lines...

Post 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?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Automatic splitting code across lines...

Post 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?!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Automatic splitting code across lines...

Post 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:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
skywalk
Addict
Addict
Posts: 3939
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Automatic splitting code across lines...

Post by skywalk »

Yeah, I had to paste in the latest compiled scintilla dll according to this...
http://www.purebasic.fr/english/viewtop ... 51#p391251
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re:

Post 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!
User avatar
ostapas
Enthusiast
Enthusiast
Posts: 192
Joined: Thu Feb 18, 2010 11:10 pm

Re: Automatic splitting code across lines...

Post 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 :)
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Automatic splitting code across lines...

Post by DoubleDutch »

:)

I thought they were going to build it in...
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
BarryG
Addict
Addict
Posts: 3186
Joined: Thu Apr 18, 2019 8:17 am

Re:

Post by BarryG »

freak in 2008 wrote:I can add the option, its no problem.
Bump. :)
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Automatic splitting code across lines...

Post by DoubleDutch »

Bump, Bump! :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
freak
PureBasic Team
PureBasic Team
Posts: 5928
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Automatic splitting code across lines...

Post by freak »

quidquid Latine dictum sit altum videtur
User avatar
idle
Addict
Addict
Posts: 4964
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Automatic splitting code across lines...

Post 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:
Post Reply