QOwnNotes icon indicating copy to clipboard operation
QOwnNotes copied to clipboard

Full indent for list sub-items

Open ivanpirog opened this issue 4 years ago • 19 comments

Actual behaviour:

QON Actual

Expected behaviour:

QON Expected

ivanpirog avatar Jan 14 '20 11:01 ivanpirog

Can you please explain in more detail and step by step what you did, what happened and what you expected.

pbek avatar Jan 14 '20 12:01 pbek

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.

QON Actual

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.

QON Expected

The screenshot shows that the second line of the long subitem sentence does not start at the very beginning of the line, but indented.

ivanpirog avatar Jan 14 '20 12:01 ivanpirog

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?

pbek avatar Jan 14 '20 12:01 pbek

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).

ivanpirog avatar Jan 14 '20 12:01 ivanpirog

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.

ivanpirog avatar Jan 14 '20 12:01 ivanpirog

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 avatar Jan 14 '20 13:01 ivanpirog

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:

Waqar144 avatar Jan 14 '20 13:01 Waqar144

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:

Waqar144 avatar Jan 14 '20 13:01 Waqar144

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.

pbek avatar Jan 14 '20 13:01 pbek

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.

pbek avatar Jan 15 '20 07:01 pbek

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 :(

ivanpirog avatar Jan 15 '20 08:01 ivanpirog

This bug is a won't fix because QMarkdownTextEdit is pure plaintext and doesn't support any complicated formatting.

Waqar144 avatar Jan 29 '20 05:01 Waqar144

Which bug? The undo?

pbek avatar Jan 29 '20 06:01 pbek

The indenting one. (Bug/feature request)

'Undo' problem isn't a bug according to my understanding.

Waqar144 avatar Jan 29 '20 08:01 Waqar144

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)

pbek avatar Jan 29 '20 11:01 pbek

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.

nonplayer avatar Oct 04 '21 00:10 nonplayer

So far there is no solution for it.

pbek avatar Oct 04 '21 04:10 pbek

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.

hbarel avatar Mar 01 '22 11:03 hbarel

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.

carhe avatar Apr 10 '22 11:04 carhe