Q. TSE: Does anyone have or use such a wrap TSE macro?

40 views
Skip to first unread message

knud van eeden

unread,
Jun 3, 2025, 11:28:44 AM6/3/25
to SemWare TSE Pro Text Editor
 
 Q. TSE: Does anyone have or use such a wrap TSE macro?

Given: You have some text and want to wrap it at the position of the cursor vertically downwards.

===

1. E.g. before this text (note: that is e.g. a one-liner here in this example)

Testing: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque porro quisquam est qui dolorem ipsum quia dolor sit amet 

===

2. E.g. Then after it is wrapped vertically downwards at the current position of the cursor (thus put after 'Testing: ') put inside that line.

Testing: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
         porro quisquam est qui dolorem ipsum quia dolor sit amet
         

===

Note: I do have a solution for it and use that solution very frequently.

      It is thus assumed to be a very frequently occurring operation
      on given text for almost anybody.

      But thus being at least curious and wondering if such a solution
      maybe already existed out of the box in default TSE (e.g. checked
      e.g. 'align' in potpourri, checked 'wrappara' e.g. for parameters, ...)

      Or somebody already published and or using such an algorithm?

with friendly greetings
Knud van Eeden

zhong zhao

unread,
Jun 3, 2025, 9:05:24 PM6/3/25
to SemWare TSE Pro text editor
Use LeftMargin, RightMargin and  WrapPara()
Ref:

Reformats a paragraph from the current cursor position to the end of the
paragraph.

Syntax:     INTEGER WrapPara()

Returns:    Non-zero if successful; zero (FALSE) on failure.

Notes:      WrapPara() looks forward for a non-blank line, if executed when
            the cursor is on a blank line.

            WrapPara() computes two values to control the reformatting
            process:  Indent and Effective Left Margin.

            ?Indent is set to the column containing the first non-white
              character on the current line.

            ?If the AutoIndent variable is set to ON or STICKY, the Effective
              Left Margin is set to the column containing the first non-white
              character on the next line.

            ?If the AutoIndent variable is set OFF, the Effective Left Margin
              is set to the value of the LeftMargin variable or, if the
              setting is zero, it is set to 1.

            WrapPara() reformats such that the current line beginning position
            is not changed, each subsequent reformatted line begins at the
            Effective Left Margin, and no characters on each line are in a
            position greater than the RightMargin variable.  However, if a
            single word, when begun at the Effective Left Margin or Indent,
            overruns the RightMargin setting, it is allowed to do so.  For
            instance, if RightMargin is set to 1, a single word is placed on
            each line.

            A word's punctuation is always kept with the word.  Trailing white
            characters are always stripped from lines being reformatted.

            WrapPara continues processing until it reaches a condition
            specified by the ParaEndStyle variable.  If ParaEndStyle is:

            ?0 (default) - Continue WrapPara process until a blank line
              or the end of the file is encountered.

            ?1 - Same as 0 but also stops when a line is encountered
              whose first non-white character is in the indent column.
              (This option supports indented and outdented paragraphs.)

See Also:   WrapLine()

            Variables:  LeftMargin, RightMargin, AutoIndent, ParaEndStyle,
                        WordWrap

knud van eeden

unread,
Jun 4, 2025, 4:33:37 AM6/4/25
to SemWare TSE Pro text editor
That does not seem to do what is intended:

PROC Main()
 Set( ParaEndStyle, 0 )
 WrapPara()
END

or also:

PROC Main()
 Set( ParaEndStyle, 1 )
 WrapPara()
END

As it does not wrap the text straight vertically down at
the cursor position (e.g. column 12) but wraps it from the beginning of the line starting from column 1.

Result of running both macros on top :

Testing: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
porro quisquam est qui dolorem ipsum quia dolor sit amet

Instead of the wanted:

Testing: The quick brown fox jumps over the lazy dog.           Lorem Ipsum Neque
         porro quisquam est qui dolorem ipsum quia    

See also the screenshot where it is better visible what is meant:
      
Inline image


with friendly greetings
Knud van Eeden






--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/semware/d5f35000-40d1-4204-933d-95454dd860den%40googlegroups.com.

zhong zhao

unread,
Jun 4, 2025, 9:28:28 PM6/4/25
to SemWare TSE Pro text editor
proc main()
    integer ai,ope,olm,orm,col

    ai=Query(AutoIndent)
    ope=Query(ParaEndStyle)
    olm=Query(LeftMargin)
    orm=Query(RightMargin)
    col=CurrPos()
    Set(AutoIndent,OFF)
    Set(Leftmargin,col)
    Set(RightMargin,80)
    Set(ParaEndStyle,1)
    WrapPara()
    Set(AutoIndent,ai)
    Set(Leftmargin,olm)
    Set(RightMargin,orm)
    Set(ParaEndStyle,ope)
end

Joe Berry

unread,
Jun 4, 2025, 10:04:13 PM6/4/25
to sem...@googlegroups.com, zhong zhao
Nice!

knud van eeden

unread,
Jun 5, 2025, 4:49:56 AM6/5/25
to SemWare TSE Pro text editor

knud van eeden

unread,
Jun 5, 2025, 5:12:31 AM6/5/25
to SemWare TSE Pro text editor, S.E. Mitchell
1. As an improvement to make it even more stand alone is to use instead of this hard coded 80 (which is actually the TSE 'right margin' value) is to instead of hard coding it, so reading it as it is already known in the variable 'orm'.

proc main()
    integer ai,ope,olm,orm,col

    ai=Query(AutoIndent)
    ope=Query(ParaEndStyle)
    olm=Query(LeftMargin)
    orm=Query(RightMargin)
    col=CurrPos()
    Set(AutoIndent,OFF)
    Set(Leftmargin,col)
    Set(RightMargin,orm) // changed 80 here to the current read value of the right margin
    Set(ParaEndStyle,1)
    WrapPara()
    Set(AutoIndent,ai)
    Set(Leftmargin,olm)
    Set(RightMargin,orm)
    Set(ParaEndStyle,ope)
end

===

2. I think this should be made part of the default TSE tool box, e.g. via a key assignment in the .ui (it should be a key because
it should be easy accessible, e.g. putting it in the PotPourri would require too much keystrokes (e.g. 3 keys pressing 'u' 'u', 'w' instead of 1 key pressing e.g. <F12> Wrap(). I use e.g. <Alt PgUp> for it).

Because this vertical alignment down from the current current cursor position down is such a frequently needed operation, every day multiple times.

I use it thus all the time.

===

E.g. BEFORE:

note 1: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque porro quisquam est qui dolorem ipsum quia dolor sit amet. The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque porro quisquam est qui dolorem ipsum quia dolor sit amet

note 2: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque porro quisquam est qui dolorem ipsum quia dolor sit amet. The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque porro quisquam est qui dolorem ipsum quia dolor sit amet

note 3: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque porro quisquam est qui dolorem ipsum quia dolor sit amet. The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque porro quisquam est qui dolorem ipsum quia dolor sit amet

===

E.g. AFTER:

E.g. AFTER:

note 1: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
        porro quisquam est qui dolorem ipsum quia dolor sit amet. The
        quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
        porro quisquam est qui dolorem ipsum quia dolor sit amet

note 2: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
        porro quisquam est qui dolorem ipsum quia dolor sit amet. The
        quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
        porro quisquam est qui dolorem ipsum quia dolor sit amet

note 3: The quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
        porro quisquam est qui dolorem ipsum quia dolor sit amet. The
        quick brown fox jumps over the lazy dog. Lorem Ipsum Neque
        porro quisquam est qui dolorem ipsum quia dolor sit amet

with friendly greeetings
Knud van Eeden




knud van eeden

unread,
Jun 6, 2025, 8:00:56 AM6/6/25
to SemWare TSE Pro text editor, S.E. Mitchell
> I use it thus all the time

E.g. a very important use case about why one should use it (very frequently / continuously):

Typically one reads text files (e.g. copy/pasted from other sources) or creates a text file in TSE,
but some of the lines are so long that they extend behind the monitor screen
to the right.

So one wants to see that hidden text in an easy way.

One could of course use the usual wrap() of the line.

But this TSE macro does and a wrap (while obeying the user chosen or default set 'right margin')
but thus additionally highlights indentations, where applicable, by
adding those extra spaces in front of the wrapped text automatically.

So making the text (e.g. long lines) better visible and readable (better indentation) for oneself and others
where applicable.

knud van eeden

unread,
Jun 10, 2025, 5:26:10 AM6/10/25
to SemWare TSE Pro text editor
FYI: But it seems not to work as expected on TSE for Linux version 4.50 official release on Linux WSL Ubuntu 


proc main()
    integer ai,ope,olm,orm,col

    ai=Query(AutoIndent)
    ope=Query(ParaEndStyle)
    olm=Query(LeftMargin)
    orm=Query(RightMargin)
    col=CurrPos()
    Set(AutoIndent,OFF)
    Set(Leftmargin,col)
    Set(RightMargin,orm) // changed 80 here to the current read value of the right margin
    Set(ParaEndStyle,1)
    WrapPara()
    Set(AutoIndent,ai)
    Set(Leftmargin,olm)
    Set(RightMargin,orm)
    Set(ParaEndStyle,ope)
end

Reply all
Reply to author
Forward
0 new messages