Need to set tab STOPS, not spacing.
-
This was just an example to show how it might look like
but I understand that for cobol one layout and for asm the other layout should be done. Just unsure what else needs to be checked.
Haven’t done anything in this area yet.Edit: btw - I’ve pinged back :-)
-
@Ekopalypse said in Need to set tab STOPS, not spacing.:
but I understand
Okay, from your screenshot it seemed apparent that you DIDN’T understand. But now I DO think you understand. :-)
BTW, ping echo received…next packet being formulated. :-)
-
- Yes, I am looking for something like what you’ve pictured
- Yes, it would only be used with fixed-spaced fonts. Why would anyone need or want a proportional font with program source code?
- Short testing? Assigned to each line? Reapplied if buffer get(s) reactivated? Please explain. Have you actually done this, tested it, etc.?
- If it can be achieved with a scripting language plugin, does such a plugin exist? If not, where are the specifications for writing such a plugin?
-
Yes, it would only be used with fixed-spaced fonts. Why would anyone need or want a proportional font with program source code?
No idea, but who knows :-)
Short testing? Assigned to each line? Reapplied if buffer get(s) reactivated? Please explain. Have you actually done this, tested it, etc.?
If it can be achieved with a scripting language plugin, does such a plugin exist? If not, where are the specifications for writing such a plugin?
Scintilla, the underlying control npp uses, provides functions which seem to do what you try to achieve.
I used PythonScript to give it a quick test to see if it is possible at all and it looks like it is. (tabs in my screenshot were created by using PythonScript)To my knowledge there are currently a python, lua, javascript and an activex (not sure if this still works)
scripting plugins available which can be used to manipulate scintilla/notepad++.But a dedicated plugin doing the same can be developed as well.
What I’ve found out, what needs to be done so far is the following
- determine the pixel size of the current used font
- on_buffer_activated callback (is called on open doc or when switching from another doc) apply the tabstops to every line of code
- on_update_ui (is called whenever something change in the current document) do the same or find a clever algo to identify the changed/new lines
I can try to create a pythonscript, which means you have to install the pythonscript plugin,
but don’t expect it to work without errors as I haven’t done anything related to tabstops yet. -
@ekopalypse What happened to this thread? Did somebody manage to define variable widths between tab stops? For the older fixed-format languages (dating back to punch cards) it would be a very useful feature.
-
@paul-wormer said in Need to set tab STOPS, not spacing.:
What happened to this thread?
I think what happened is that the OP didn’t respond and express continued interest, so @Ekopalypse didn’t continue expending effort on it.
I would like to see such a thing, but where no tab characters are used (only spaces). I think I could put that to some good use, but until I see it I won’t know for sure.
-
@alan-kilborn
If I’m correctly understanding the problem the OP was asking for, it sounds like the old ways we were able to setup a wordprocessor like WordPerfect and such, so that you set the tab stops at predefined areas you wanted to start sections at instead of having auto indents setting of so many spaces. When I see Tabs in a menu option, I personally expect to see that kind of a reference (tab stops) rather than shortcuts to choose a different tab (window/folder). :-)I suspect, the implementation may be difficult since you have the column editing ability, and that may conflict with tabbing as a formatting tool?
Lee
-
@lycan-thrope said in Need to set tab STOPS, not spacing.:
instead of having auto indents setting of so many spaces
Yes, I do realize my desire is somewhat “against the grain” of the OP’s request (the title of this thread, after all, is Need to set tab STOPS, not spacing).
But, for it (the general concept of a proposed solution) to be useful to me, it would have to consider spaces, because tab characters in my files are not allowed.
-
Yep, which is why the option of choosing the number of spaces to substitute for a tab was implemented in those old word processors. :-) They were, at the time, the best multi-tool we had, until syntax-highlighting became a desired tool for programmers and the editors took different directions at that point, for the most part, as I remember it. :-)
Lee
-
A little experimentation on my own shows that the Scintilla functions for this only work when true tab characters are used, and I have zero interest in that, so… I’m out.
-
@alan-kilborn said in Need to set tab STOPS, not spacing.:
when true tab characters are used
but after they’re inserted, can’t you have N++ set to convert to space?
Cheers.
-
@michael-vincent said in Need to set tab STOPS, not spacing.:
but after they’re inserted, can’t you have N++ set to convert to space?
My experiment was:
- create new file tab with Ctrl+n
- execute Pythonscript
editor.clearTabStops(0)
in console - execute Pythonscript
editor.addTabStops(0, 100)
in console - move focus to editor (on line 1 since empty file); press Tab key a few times (observe insertion of four space characters each time)
- go to Preferences, change Default file type setting to not replace with spaces
- move focus back to editor line 1; delete previously entered spaces; press Tab key a few times; observe:
So I do see an effect, but only when tab characters are used. (Another thing to note is that the “indent lines” don’t seem to respect tab stops that are not regular).
Thus I don’t see how to achieve anything with only space characters. Or maybe you had some other idea?
-
@alan-kilborn said in Need to set tab STOPS, not spacing.:
Or maybe you had some other idea?
No, that about sums up my thoughts on the matter :-) Thanks for the testing explanation.
Cheers.
-
I just started programming in Assembly again after a 30 year hiatus and straight away I wanted to set tab stops!
label tab move.l tab d1,d0 tab ; I dig 68000 in 3 tabs
not
label tab tab tab tab move.l tab tab tab d1,d0 tab tab tab ; i dig 68000 in 9 tabs
So I stared digging. A very long time ago, probably in the late 1980s the tabstop message EM_SETTABSTOPS was coded to provide the functionality but the units used to determine the distance were “dialog units”. The only function to convert pixels to dialog units, MapDialogRect, specifically requires a dialog box handle, HWND. Well this is totally dumb because editors always exist in a program’s main form not in a dialog box. So without an official way forward to effectively calculate the distance I think folks just quit enabling the old smart typewriter tab stop settings in editors based on the textbox or richedit canned windows controls.
Sure MS Word had them, they probably coded a work around for their own editor but anyone else trying to make their custom editor for Windows didn’t bother with it. Also Microsoft office programs never appeared to use the controls provided in their “c++” development package.
Stackoverflow posts today say they just approximate the conversion. C# didn’t even bother implementing it. I suppose you could code up a dummy application just to figure out the proper ratio and make your own MapDialogRect function.
You can find post after post of people trying to convert pixels and dialog units, LOL. Another fine traditional mess Microsoft has managed to maintain after 40 years. “We’ll make typewriters and key punches with their damn tab stops obsolete!”
This is also an example of how sick Windows actually is on the inside. Look it’s Windows 95! Fancy menus and desktop! Look it’s Windows 11! Fancy menus and a desktop! Both housing the same old broken tabstop problem that will never be fixed.
Couldn’t Microsoft add a new EM_SETTABSTOP parameter setting that would allow a pixel argument? That’s the thing, I don’t think they mess with any of that old code at all, I think it will stay the same indefinitely. That’s what “Windows” is to me, the ragtag collection of code that makes up the basic core system that they drag around like an anchor year after year.
-
Your posting seems like a Microsoft rant, as you didn’t mention Notepad++ once. If so, this is off-topic for this forum.
If you’re really expressing a Notepad++ desire, you need to say so, and maybe one of the earlier posters will help you achieve your goal.
-
@Brian-L-Hughes said in Need to set tab STOPS, not spacing.:
I just started programming in Assembly again after a 30 year hiatus and straight away I wanted to set tab stops!
If Notepad++ can do what you desire then it’s not obvious to me. It’s possible the ElasticTabStops plugin from from @mariusv-github can do it. I installed the plugin last night but could not get it to do what I hoped.
It’s also possible the Columns++ plugin from @Coises can do it. I gave Columns++ a quick spin but again did not see an obvious way to define tab stops.
The lack of user-defined tab stops is strange as it’s easy on manual typewriters. I believe many keyboard driven card punches had settable tab stops as it seemed that typing code was fast and easy in those days. User-defined tab stops never became popular on serial line computer terminals starting with the Teletype Model 33 and the CRT versions where fixed 8x spacing became the rule.
For others, assembly language has traditionally used 8x tab stops and uses four columns with the layout being
label opcode operands comments
The columns in assembler text are:
label
is optional and when present it nearly always starts in text column 1. Some people use a coding style where the labels are on their own line while others will uselabel tab opcode ...
.opcode
is nearly always lined up in a column.operands
is optional and tends to be lined up in a column. As operands are associated with an opcode you will always see... opcode tab operands ...
comments
are optional and nearly always are prefixed with a delimiter. It’s a coding style thing. Some people put comments in a column to the right of operands. It’s also common to see comments in text column 1 and less common that someone indents them in the opcode or operands column.
Most of the applications that convert human text readable code into binary machine code don’t care that much about spaces vs. tabs and don’t care about repeated spaces and/or tabs.
As assembly languages tend to be free format I personally don’t see an issue with someone having user-defined tab stops as long as they are not ever sharing their code with others. If the files use tab characters in their files it certainly will play havoc with the minds of other humans if their tab stops don’t match the user defined stops. A text editor that uses spaces instead of tabs to line things up likely will bother some people.
-
@mkupper said in Need to set tab STOPS, not spacing.:
If Notepad++ can do what you desire then it’s not obvious to me. It’s possible the ElasticTabStops plugin from from @mariusv-github can do it. I installed the plugin last night but could not get it to do what I hoped.
The current version of ElasticTabstops is, in my opinion, broken. Its author took over the name (while stating clearly that he did not intend to “take over the development of the plugin”) from the previous version (which didn’t work on 64-bit) and promptly abandoned it.
It’s also possible the Columns++ plugin from @Coises can do it. I gave Columns++ a quick spin but again did not see an obvious way to define tab stops.
The Elastic tabstops function in Columns++ can help if you want to separate each column from the next by a single tab, you want the columns to line up visually, but you don’t care at which specific columns they line up. (That’s the “elastic” part — they expand or contract based on content.)
@Alan-Kilborn said in Need to set tab STOPS, not spacing.:
o I do see an effect, but only when tab characters are used. (Another thing to note is that the “indent lines” don’t seem to respect tab stops that are not regular).
Thus I don’t see how to achieve anything with only space characters. Or maybe you had some other idea?
If what you want is for the tab key to insert a number of spaces, depending on the position of the cursor and following a simple rule, I suggest creating a script that implements that rule, then using the Shortcut mapper to remove the Tab key from SCI_TAB and assign it to your script. (You could even make the script smart enough to position the cursor at the next column if there is already text there, and only insert space when it’s at the end of a line.)
If someone wanted to write a plugin, it could include the ability to specify the exact tabstops for different file types and activate based on the file extension and/or the language. I don’t know if that degree of complexity is practical in a script.
-
@Coises said in Need to set tab STOPS, not spacing.:
If what you want is for the tab key to insert a number of spaces, depending on the position of the cursor and following a simple rule, I suggest creating a script that implements that rule, then using the Shortcut mapper to remove the Tab key from SCI_TAB and assign it to your script. (You could even make the script smart enough to position the cursor at the next column if there is already text there, and only insert space when it’s at the end of a line.)
If someone wanted to write a plugin, it could include the ability to specify the exact tabstops for different file types and activate based on the file extension and/or the language. I don’t know if that degree of complexity is practical in a script.
If I knew what I was doing and was more familiar with the editor and the Scintilla messages, etc, I would probably start with the existing feature
Settings->Preferences...->Margins/Border/Edge->Vertical Edge Settings
and depending on where the cursor is, hitting tab would take it to the next set Vertical Edge. Since those are set apparently by column number, however NPP calculates that to be, it would seem the logical place to look to use as reference for where to tab to. For instance, I try to keep my text to 80 columns (as in this screenshot):…so it doesn’t extend beyond the dBASE editor’s windows boundaries so I don’t have to scroll back and forth reading code in that Editor.
Just a thought, if I was a more capable NPP plugin or Python coder. :-)