numere-org / NumeRe

Framework for numerical computations, data analysis and visualisation
https://www.numere.org
GNU General Public License v3.0
18 stars 6 forks source link

Provide autowrapping for comments, if line length indicator is active #16

Closed numeredev closed 10 months ago

numeredev commented 1 year ago

DESCRIPTION

What does your feature request improve on? Please describe. Automatic line wrapping would render the line length indicator far more usable than it currently is.

Describe the solution you'd like Provide an option and functionality to handle the line wrapping of (documentation) comments, if the user activated the line length indicator (like in MATLAB). Should be active, if the user adds a character somewhere in a comment line. If a character is removed, it should not do anything. Style has to be copied from the previous line (keeping documentation comments).

Additional context Migrated from here: https://sourceforge.net/p/numere/tickets/775/

(Do not write below this line)


DEVS' SECTION

ANALYSIS

Can be linked into the NumeReEditor::OnChar() event handler. Use the NumeReEditor::isStyleType() function to detect, whether the cursor is currently within a comment line or a comment block (might also be one char right of that -- check that) and if the line length indicator is active and if the line length is longer than the length indicator. Calculate then a correct linebreak position (you may use an adaption of NumeReEditor::addLinebreaks() to do that) and insert the line break as "\r\n".

If the following line is also a comment line (check, whether the style values are identical), then prefix the wrapped contents to this line (possibly creating a recursion). Otherwise simply create a new line with the corresponding style type.

IMPLEMENTATION STEPS

(see also our Wiki for implementation guidelines)

DOCUMENTATION STEPS

(see also our Wiki for further information)

PULL REQUEST

MarkRamp commented 1 year ago

image This is the line indicator option, isn't it?

numeredev commented 1 year ago

image This is the line indicator option, isn't it?

Exactly

MarkRamp commented 11 months ago

I'm struggling currently to find the variable which will tell me if line indicator is on/off. Where can I find it?

numeredev commented 11 months ago

I'm struggling currently to find the variable which will tell me if line indicator is on/off. Where can I find it?

m_options->getSettings()[SETTING_B_LINELENGTH].active()

MarkRamp commented 11 months ago

Kannst du mir mal erklären, warum GetCurrentPos() hier 519 (print ist in OnChar Event von editor.cpp) zurückgibt?

image

numeredev commented 11 months ago

Das ist die logische Position vom Start des Dokuments, deswegen.

numeredev commented 11 months ago

You want to try with GetColumn(GetCurrentPos())

MarkRamp commented 11 months ago

noch eine Frage, schielßen sich die Optionen STYLE_COMMENT_LINE, STYLE_COMMENT_BLOCK, STYLE_COMMENT_SECTION_LINE und STYLE_COMMENT_SECTION_BLOCK gegenseitig aus? oder kann currentPos gleichzeitig zwei oder mehrere Style Typ sein?

numeredev commented 11 months ago

Am besten einfach hier nachschauen: bool NumeReEditor::isStyleType(StyleType _type, int nPos), aber STYLE_COMMENT_SECTION_LINE sollte Teil von STYLE_COMMENT_LINE sein (und dasselbe für *_BLOCK)

MarkRamp commented 10 months ago

sorry für die zahlreichen Fragen, aber wie sehen STYLE_COMMENT_SECTION_LINE und STYLE_COMMENT_SECTION_BLOCK aus? Ich konnte leider kein Beispiel für beiden finden.

numeredev commented 10 months ago

sorry für die zahlreichen Fragen, aber wie sehen STYLE_COMMENT_SECTION_LINE und STYLE_COMMENT_SECTION_BLOCK aus? Ich konnte leider kein Beispiel für beiden finden.

## == STYLE_COMMENT_LINE #* ... *# == STYLE_COMMENT_BLOCK ##! == STYLE_COMMENT_SECTION_LINE (Dokumentationskommentar) #*! ... *# == STYLE_COMMENT_SECTION_BLOCK (Dokumentationskommentar)