0x7c13 / Notepads

A modern, lightweight text editor with a minimalist design.
https://www.NotepadsApp.com
MIT License
8.69k stars 479 forks source link

Tabulation is wrong comparing to original Notepad #19

Open entdark opened 5 years ago

entdark commented 5 years ago

Notepad: Notepad Notepads: Notepads Sample text (looks fine on GitHub as well):

1234567     tabbed
12      tabbed
0x7c13 commented 5 years ago

Did you select "\t" for the tabs? tab

entdark commented 5 years ago

Did you select "\t" for the tabs? tab

Yes

entdark commented 5 years ago

I did a few tests.

Tabulation in original Notepad takes 8 characters. Tabulation in Notepads takes 5 characters. Tabulation in Sublime Text takes 4 characters and has a similar looking "issue" as Notepads. But there is an option in Sublime Text to change the size of tabulation.

I guess you could add an option to change the tabulation size in characters to Notepads? Don't confuse with spaces option.

0x7c13 commented 5 years ago

1234567 tabbed 12 tabbed

Just want to confirm, there are two tabs in between right?

0x7c13 commented 5 years ago

Annotation 2019-07-05 222648

entdark commented 5 years ago

There is a sample text in the first post.

0x7c13 commented 5 years ago

I tried that one and yes I can repro what you have described but I do not think I can/should solve it since I am using default RichEditBox behavior as I have found in other usages as well:

Annotation 2019-07-07 200705

entdark commented 5 years ago

Yeah, I understand it's not a bug to solve, but more like an enhancement to make to change the tabulation size. Could you implement such a feature?

Because I have plenty documents that have a lot of tabulations that I already made in original Notepad, but I cannot work with them in Notepads because tabulation is wrong on every line.

entdark commented 5 years ago

Could that property do the trick: https://docs.microsoft.com/en-us/uwp/api/windows.ui.text.itextdocument.defaulttabstop#Windows_UI_Text_ITextDocument_DefaultTabStop ? RichEditBox.Document.DefaultTabStop = 72.0f; Or other value that user selected where 4 characters equals 36.0f.

0x7c13 commented 5 years ago

Yes, RichEditBox.Document.DefaultTabStop is the right one and the reason I do not want to change it is because it is very flaky by my observation. Let me try it again to see if it can help. Btw, it is not just changing the RichEditBox.Document.DefaultTabStop, I need to change it every single time when font changes as well. Check it here: https://github.com/JasonStein/Notepads/blob/master/src/Notepads/Controls/TextEditor/TextEditor.cs (Search for SetDefaultTabStop)

entdark commented 5 years ago

Fortunately, we don't change font often, do we? Would be nice if you could find out the solution for changing the tabulation size. That tabulation issue is actually the only reason that stops me using Notepads as a main text editor.

0x7c13 commented 5 years ago

OK, I will take a deep look later this week to see what I can do for you.

AmionSky commented 5 years ago

I looked at it for a bit and it looks like changing the DefaultTabStop does not apply it for the first tab stop of the line. Ex: tab stop set to 200.0f in code: image

entdark commented 5 years ago

I looked at it for a bit and it looks like changing the DefaultTabStop does not apply it for the first tab stop of the line.

Interesting. Also distance between 1 and 2 is smaller than between 2 and 3. Are you sure you applied that correctly? Jason showed it is used in several places.

0x7c13 commented 5 years ago

@entdark , I can confirm with what @AmionSky described. The first tab stop is not controlled by us. Unfortunately, there is nothing we can do about it.

AmionSky commented 5 years ago

I think so. I changed SetDefaultTabStop

private void SetDefaultTabStop(FontFamily font, double fontSize)
{
    Document.DefaultTabStop = 200.0f;
    TextDocument.DefaultTabStop = 200.0f;
}

But it looks like the distance from 0->2 is the same as 2->3

entdark commented 5 years ago

Hm, seems like I will try to dig into that problem myself then. Thanks for attempts, guys. Btw, according to docs TextDocument is Document, just differ by type. So setting DefaultTabStop in one of them is enough, and no need to set that again for another one. https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.richeditbox.textdocument

entdark commented 5 years ago

I also did a few tests, and seems like it's really a bug in UWP SDK. Changing font family and font size doesn't affect the first tabulation as well. I will try to write a bug report to Microsoft.

soumyamahunt commented 4 years ago

@JasonStein I just tested the sample and it seems Wordpad, Microsoft Word and Notepads produce similar results while Notepad produces a different result. May be this has to do with RichEditBox control being designed for .rtf files and tab behavior for word processors are different than text editors??