QOwnNotes
QOwnNotes copied to clipboard
Full indent for list sub-items
Actual behaviour:
Expected behaviour:
Can you please explain in more detail and step by step what you did, what happened and what you expected.
Ok. I press Tab to indent the new list item. The Tab key indents 4 spaces from the beginning of a line. Then I write a long sentence that wraps on the next line...
Current behavior:
The wrapped text of a long subitem sentence is displayed from the very beginning of the line.
The screenshot shows that the second line of the long subitem sentence starts from the very beginning of the line. The arrows indicate this.
Expected Behavior:
The wrapped text of a long subitem sentence is displayed indented, which is equal to the number of spaces from the beginning of the line, including the asterisk and a space after it.
The screenshot shows that the second line of the long subitem sentence does not start at the very beginning of the line, but indented.
Thank you for your explanation. I don't know if you can even alter the soft wrap mechanism and if it is possible it sounds like a lot of work. :grimacing:
@Waqar144, have you ever played with indents of the soft-wrapping?
if it is possible it sounds like a lot of work. 😬
Yeah, I already looked at the source code and realized that the task is difficult (at first glance).
I look at:
void QTextBlockFormat::setIndent ( int indentation ) void QTextCursor::setBlockFormat ( const QTextBlockFormat & format )
But it looks like it sets the indent for the entire paragraph.
If it is possible to set both indent for the entire paragraph and indent from the beginning of the line, then indent from the beginning of the line can be made negative.
Possible steps:
- Get a list item string
- Get spaces from the start of the line: ^(\s+)
- Get paragraph font size
- SpacesWidthInPixels = Get width in pixels of spaces from the start of the line using QFontMetrics::width (https://doc.qt.io/archives/qt-4.8/qfontmetrics.html#width)
- QTextBlockFormat::setTextIndent(-SpacesWidthInPixels)
- QTextBlockFormat::setLeftMargin(SpacesWidthInPixels)
Thank you for your explanation. I don't know if you can even alter the soft wrap mechanism and if it is possible it sounds like a lot of work. grimacing
@Waqar144, have you ever played with indents of the soft-wrapping?
Nah. I always understood wrapping as something only for the end of the line, not the start of the next one :laughing:
Possible steps:
1. Get a list item string 2. Get spaces from the start of the line: ^(\s+) 3. Get paragraph font size 4. SpacesWidthInPixels = Get width in pixels of spaces from the start of the line using QFontMetrics::width (https://doc.qt.io/archives/qt-4.8/qfontmetrics.html#width) 5. QTextBlockFormat::setTextIndent(-SpacesWidthInPixels) 6. QTextBlockFormat::setLeftMargin(SpacesWidthInPixels)
@ivanpirog looks like you are already on way to solving the issue :rocket:
Yes, https://doc.qt.io/qt-5/qtextblockformat.html#setTextIndent and https://doc.qt.io/qt-5/qtextblockformat.html#setLeftMargin sound like a good way.
I tried some stuff, but had my issues with it...
QTextBlockFormat blockFormat = currentBlock().blockFormat();
// didn't do anything for me
blockFormat.setTextIndent(100);
// didn't do anything for me
blockFormat.setLeftMargin(50);
auto* myCursor = new QTextCursor(currentBlock());
// this prevents "undo"
myCursor->setBlockFormat(blockFormat);
Issues like broken "undo" already did came up previously when I tried to introduce a bottom margin for headlines.
QTextBlockFormat blockFormat = currentBlock().blockFormat(); // didn't do anything for me blockFormat.setTextIndent(100); // didn't do anything for me blockFormat.setLeftMargin(50);
Yeah, I have the same results :(
This bug is a won't fix because QMarkdownTextEdit
is pure plaintext and doesn't support any complicated formatting.
Which bug? The undo?
The indenting one. (Bug/feature request)
'Undo' problem isn't a bug according to my understanding.
If a QPlainTextEdit can't do it it currently can't be done. Except we want to pay the price for switching back to a QTextEdit (speed, memory consumption, possibly missing features that currently work)
I know this is way over a year old, but hey it's still technically open. I came here to post a request for this same feature. I don't know if it would be any easier at all to implement now, but I figured I'd ask. Bullet-aligned list-wrapping indents would be wonderful. Thanks.
So far there is no solution for it.
I can only add a "+1" for the need. I was just about to post it as a suggested feature and saw that it's already there...
I realize it is not doable, though.
Same for me, I was on the way to suggest the feature and found this issue.
For people structuring (longer) thougths in hierarchical lists the indent feature is quite important. Without indentation the visual structure of the text gets lost, and with nested items it gets unclear which of the items the unintended text continues. The current workaround is to indent the text manually, which is really awkward because changing the window size and in consequence the line length breaks everything (this typically happens when one wants to export or print the text).
Just some background to support my +1.