magiblot / turbo

An experimental text editor based on Scintilla and Turbo Vision.
Other
442 stars 35 forks source link

Can't change tab size. #62

Open skywind3000 opened 7 months ago

skywind3000 commented 7 months ago

My favorite tabsize is 4, but the default is 8 in turbo, and I can't find a way to change it.

magiblot commented 7 months ago

Hi Linwei!

Unfortunately, this cannot be currently customized from within the application. It requires changing the source code and rebuilding Turbo.

You have to modify source/turbo-core/editor.cc as follows:

--- a/source/turbo-core/editor.cc
+++ b/source/turbo-core/editor.cc
@@ -31,6 +31,7 @@ Editor::Editor(TScintilla &aScintilla) noexcept :
     // Indentation
     call(scintilla, SCI_SETUSETABS, false, 0U);
     call(scintilla, SCI_SETINDENT, 4, 0U);
+    call(scintilla, SCI_SETTABWIDTH, 4, 0U);
     call(scintilla, SCI_SETTABINDENTS, true, 0U);
     call(scintilla, SCI_SETBACKSPACEUNINDENTS, true, 0U);

Also, if you wish the tabulator key to insert tab characters instead of whitespace characters, also add this change:

-    call(scintilla, SCI_SETUSETABS, false, 0U);
+    call(scintilla, SCI_SETUSETABS, true, 0U);
skywind3000 commented 7 months ago

fair, this project is an experiment.

I came from a discussion: https://github.com/microsoft/terminal/discussions/16440

this project has been mentioned by multiple participants:

Wish this PoC can actually turn into a real editor some day.

Before that, can you just set the default tabsize to 4 please ? Default to 8 is unix flavor, not so windows.

Turbo C 2.0 and Visual Studio use 4 by default.

magiblot commented 6 months ago

Hi, Lin!

I've made up my mind. If the default tab size is 8 and this cannot be customized by the user, then it is very likely that code containing tab characters will look mostly messed up and the user will be able to do nothing. Therefore, I agree to a default tab size of 4 instead.

skywind3000 commented 6 months ago

thanks