Open entdark opened 5 years ago
Did you select "\t" for the tabs?
Did you select "\t" for the tabs?
Yes
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.
1234567 tabbed 12 tabbed
Just want to confirm, there are two tabs in between right?
There is a sample text in the first post.
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:
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.
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
.
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)
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.
OK, I will take a deep look later this week to see what I can do for you.
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:
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.
@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.
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
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
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.
@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??
Notepad: Notepads: Sample text (looks fine on GitHub as well):