Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabulation is wrong comparing to original Notepad #19

Open
entdark opened this issue Jul 5, 2019 · 19 comments
Open

Tabulation is wrong comparing to original Notepad #19

entdark opened this issue Jul 5, 2019 · 19 comments
Labels
wontfix This will not be worked on

Comments

@entdark
Copy link

entdark commented Jul 5, 2019

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

1234567		tabbed
12		tabbed
@0x7c13
Copy link
Owner

0x7c13 commented Jul 5, 2019

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

@entdark
Copy link
Author

entdark commented Jul 5, 2019

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

Yes

@entdark
Copy link
Author

entdark commented Jul 5, 2019

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
Copy link
Owner

0x7c13 commented Jul 6, 2019

1234567 tabbed
12 tabbed

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

@0x7c13
Copy link
Owner

0x7c13 commented Jul 6, 2019

Annotation 2019-07-05 222648

@entdark
Copy link
Author

entdark commented Jul 6, 2019

There is a sample text in the first post.

@0x7c13
Copy link
Owner

0x7c13 commented Jul 8, 2019

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
Copy link
Author

entdark commented Jul 8, 2019

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
Copy link
Author

entdark commented Jul 8, 2019

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
Copy link
Owner

0x7c13 commented Jul 8, 2019

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
Copy link
Author

entdark commented Jul 8, 2019

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
Copy link
Owner

0x7c13 commented Jul 10, 2019

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

@AmionSky
Copy link
Contributor

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
Copy link
Author

entdark commented Jul 11, 2019

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
Copy link
Owner

0x7c13 commented Jul 11, 2019

@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
Copy link
Contributor

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
Copy link
Author

entdark commented Jul 11, 2019

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
Copy link
Author

entdark commented Jul 13, 2019

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.

@0x7c13 0x7c13 added the wontfix This will not be worked on label Aug 8, 2019
@soumyamahunt
Copy link
Contributor

@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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants