Recent

Author Topic: "Show as Tab" - IDE directive  (Read 6878 times)

xint

  • New Member
  • *
  • Posts: 33
"Show as Tab" - IDE directive
« on: January 08, 2025, 09:46:09 am »
When I implement and test something, I usually work on 2-3 procedures or functions. These are often scattered throughout the source code, so I scroll up and down, always looking for the right procedure.
Sometimes I jump to the procedure by clicking it's event in the object inspector, but that's always a lot of clicking. Unfortunately I've never been able to make friends with the IDE's bookmarks, because that's also a lot of clicking and not very intuitive when bookmarks often change (my personal opinion).
A colleague split his source into individual units so that he can access them flexibly via tabs, what is brilliant to jump between different locations in the source easily but a hassle administratively.

Would it be feasible if there was some kind of IDE directive to display the procedure following the directive as a tab in the IDE ?

Code: Pascal  [Select][+][-]
  1. {%tab}
  2. procedure TForm1.FormShow(Sender: TObject);
> leads to a IDE-tab named 'TForm1.FormShow'.

or
Code: Pascal  [Select][+][-]
  1. {%tab Show}  // manually named tab
  2. procedure TForm1.FormShow(Sender: TObject);
> leads to a IDE-tab named 'Show'.


Selecting this 'virtual' tab would show the source as it has been already implemented in with 'open in a new window', but as a separate tab, named accordingly and the cursor (view) already located.
In this way, many places in the source code could be accessed quickly and flexibly.

cdbc

  • Hero Member
  • *****
  • Posts: 2505
    • http://www.cdbc.dk
Re: "Show as Tab" - IDE directive
« Reply #1 on: January 08, 2025, 09:54:27 am »
Hi
It's not what you're looking for, but you can use include-files, to partition your code... They'll show up on their own tab.
Just a thought...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

xint

  • New Member
  • *
  • Posts: 33
Re: "Show as Tab" - IDE directive
« Reply #2 on: January 08, 2025, 10:05:00 am »
Hi Benny,

Thanks for your suggestion. I know that I can split my source into several include files. But not every single fragment of the code worth it to be separated.
I was just suggesting a way to access different sections of code with just a single extra line of text. An ln-line bookmark that shows up as a tab - easy to watch, easy to access and (!) most easy to organize and reorganize.

Rgds, Stefan

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11895
  • Debugger - SynEdit - and more
    • wiki
Re: "Show as Tab" - IDE directive
« Reply #3 on: January 08, 2025, 10:07:40 am »
There are several ways you can currently use.

1) Multiple source windows.
Right click the tab of the existing editor for that code, and chose "Clone to other Window". Repeat this as often as you need.

- Scroll each tab to one of your functions.
- Right click the tab of each of those editors and chose "Lock" to prevent the IDE from scrolling it for code navigation. The IDE will then use an editor for that unit which is not locked => so one should be left unlocked.

2) Navigate with the code explorer and/or bookmarks

3) Fold the code between the functions
Select the code between the functions, and it will allow you to fold the selected code away.

Or fold using {%region} {%endregion}


4) Use TODO comments and the TODO window as navigation
« Last Edit: January 08, 2025, 10:09:25 am by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11895
  • Debugger - SynEdit - and more
    • wiki
Re: "Show as Tab" - IDE directive
« Reply #4 on: January 08, 2025, 10:11:47 am »
I don't think that the {%tab} idea will be done... (except if some one does it as 3rd party add on....)

What I could imagine (but don't have time for) is the sort of drop down that lists all procedures, and if you select one, the editor will show this and only this procedure....

Then that could be combined with several editor windows.

rvk

  • Hero Member
  • *****
  • Posts: 6890
Re: "Show as Tab" - IDE directive
« Reply #5 on: January 08, 2025, 10:34:03 am »
4) Use TODO comments and the TODO window as navigation
Just what I wanted to suggest. Using TODO. It's that simple.
Just type {TODO: test} and it'll add the todo to the list.
Pin your View>Todo list to you IDE and you always have the list handy.

Note... It only shows the TODO from the files you have open.
If you add "Packages" to the list... you get A LOT of TODO's from the developers in the whole FPC/Lazarus source.

Note to developers... Is that how it's supposed to work? If I want to use TODO in my own project... I also get all the TODO from everyone in the sourcecode of all packages???  %)
Shouldn't those TODO's have a separate list (TODODEV:) or be hidden from the normal users?
Or can we, as users, use a different TODO list?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11895
  • Debugger - SynEdit - and more
    • wiki
Re: "Show as Tab" - IDE directive
« Reply #6 on: January 08, 2025, 10:42:36 am »
I haven't used the TODO list much myself. So I am not sure if it can be configured.... If not, it's probably worth a feature request. E.g. maybe an directory exclusion filter.

TODO comments sneak in real easy. So they will always happen. I probably have some in there too. I just use normal search to find them.

rvk

  • Hero Member
  • *****
  • Posts: 6890
Re: "Show as Tab" - IDE directive
« Reply #7 on: January 08, 2025, 10:52:29 am »
Just with a simple empty project, adding the check for packages, I got 480 TODO's.
So if I would use it in my own project with multiple source files, my own TODO's would get under snowed by all those from developers.
Not really how that feature should work  ;D

I do see that you can give a priority to the TODO. You can sort on priority (at least that's something).
All but one TODO's in the source have priority 0. (one in typshrdh.inc has priority 2)

A filter for priority (show at least > 5) would be useful in that case :)
There is also Category which could be used... but again... no filter for that.

Luckily I don't use it much either.

https://wiki.freepascal.org/IDE_Window:_ToDo_List

Code: Pascal  [Select][+][-]
  1. {TODO 5 -oOwnerName -cCategoryName: Todo_text}
  2. {DONE 5 -oOwnerName -cCategoryName: Todo_text}
  3. {#todo 5 -oOwnerName -cCategoryName: Todo_text}
  4. {#done 5 -oOwnerName -cCategoryName: Todo_text}
  5. { ToDo: Todo_text}
  6. // ToDo: Todo_text
  7. (* ToDo: Todo_text *)

xint

  • New Member
  • *
  • Posts: 33
Re: "Show as Tab" - IDE directive
« Reply #8 on: January 08, 2025, 01:52:53 pm »
@Martin_fr
@rvk

Thank you both. That is very close to what I was looking for and a huge help !

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11895
  • Debugger - SynEdit - and more
    • wiki
Re: "Show as Tab" - IDE directive
« Reply #9 on: January 08, 2025, 02:58:49 pm »
One more: There is a 3rd party package lazstackbookmarks (google).

You can bookmark as many lines as you want, and it shows the code of the line (so if you bookmark the "procedure name" line, then you see the name).

xint

  • New Member
  • *
  • Posts: 33
Re: "Show as Tab" - IDE directive
« Reply #10 on: January 08, 2025, 03:13:12 pm »
@Martin_fr
Good suggestion. I'll give that a try, because it's list-window appears to be more space-saving and I can map keys which I did not find for ToDo's yet - expscially not for the update list button.

xint

  • New Member
  • *
  • Posts: 33
Re: "Show as Tab" - IDE directive
« Reply #11 on: January 08, 2025, 03:33:10 pm »
@Martin_fr
This was a really good find, but I'm going to stick with {todo}. I decided that, because I can name the ToDo myself, which relieves my eyes from having to find the relevant information I need in all those Form1.Procedure([...]'s. Of course, I could also edit this information in the bookmark plugin, but that requires additional actions and I like it the easy way.
Also, I placed the IDE on my vertical monitor, which give me lots of lines for the code but leaves impressively little space for the sidebar. As long as each location bookmark starts with Form1.Procedure(, the majority of the information I'm looking for may not be visually available anymore.

I'm glad I dropped my {tab} suggestion here and want to thank you all again for your attention. Your recommendation to use 'ToDo' was brilliant.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11895
  • Debugger - SynEdit - and more
    • wiki
Re: "Show as Tab" - IDE directive
« Reply #12 on: January 08, 2025, 05:22:31 pm »
Also, I placed the IDE on my vertical monitor

I use a horizontal monitor for my source editors (plural). And then all other parts of the IDE on 2ndary monitors. (I don't use docking, but it can be done with docking, using multiple dock-sites).

That way I can have 3 source editors next to each other (left to right), still get a decent amount of lines in each (full height of the screen).
And 3 source editor windows means I can have 3 functions all in view at the same time. (and they can all be in the same unit, as the IDE can display the same unit in multiple editors).

Very rarely I have to fold out some comments or "If then else" blocks, if I don't need them, but need more of the code surrounding them.




Btw, I have a feeling you may enjoy "User defined colors" https://wiki.freepascal.org/New_IDE_features_since#Multiple_user_defined_word_highlight/markup

That way, if you track an identifier (variable, type name, function name) => you can highlight it in a color (and it will show in all open editors / or if you chose, just the current editor).
So you can quickly spot all the locations.

You can have as many different colors as you want to have.

n7800

  • Hero Member
  • *****
  • Posts: 583
  • Lazarus IDE contributor
    • GitLab profile
Re: "Show as Tab" - IDE directive
« Reply #13 on: January 08, 2025, 11:59:45 pm »
I don't understand why no one mentioned the Procedure List window (Menu > Search > Procedure List)?

Just press [Alt+G] to see the list of procedures for current unit. Click the one you need or use the arrows to jump to it. Or start typing part of a procedure name to filter the list and quickly find it.

All this helps not only to navigate through the code, but also to simply study unfamiliar units. Note the combobox on the right - it contains classes (that have procedures in this unit), which also allows you to filter the list.

I use it so often that I added a couple of features for it in my personal IDE installation. They worked well, I'll have to find time to make a merge request sometime...

Tony Stone

  • Sr. Member
  • ****
  • Posts: 277
Re: "Show as Tab" - IDE directive
« Reply #14 on: January 09, 2025, 12:08:31 am »
I always use the Code Explorer... which is nice with a filter to find a function or procedure.

The Procedure List looks handy, I had no idea it was there!  Too bad its a modal form and not dockable.  But I will remember this Shortcut

Edit:
So messing with the Procedure List which is almost perfect but the problem with it is like a modal form so nothing else in the IDE can be accessed.  If it was dockable like the Code Explorer I would prefer it over the Code Explorer
I don't understand why no one mentioned the Procedure List window (Menu > Search > Procedure List)?

Just press [Alt+G] to see the list of procedures for current unit. Click the one you need or use the arrows to jump to it. Or start typing part of a procedure name to filter the list and quickly find it.

All this helps not only to navigate through the code, but also to simply study unfamiliar units. Note the combobox on the right - it contains classes (that have procedures in this unit), which also allows you to filter the list.

I use it so often that I added a couple of features for it in my personal IDE installation. They worked well, I'll have to find time to make a merge request sometime...
« Last Edit: January 09, 2025, 12:14:03 am by Tony Stone »

 

TinyPortal © 2005-2018