Recent

Author Topic: Source Editor - Open Source Folder Option  (Read 15840 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12399
  • Debugger - SynEdit - and more
    • wiki
Re: Source Editor - Open Source Folder Option
« Reply #15 on: January 28, 2025, 12:59:49 am »
Ok, got a bit late today... but at least applied the patch.

Is it supposed to paint with a white background? The rest of the panels is grey.

Click and double click don't do anything at all, only right click and menu, but then the process fails to launch.

Ah, ok, only the folder is click able. I did not guess that. Also that folder to me says "open file" (as in select a new file to open in a (new/extra) editor).
(same failed to launch)

Apparently I got the Windows (Win 10) experience...

Off to bed now, need to play with that later.

Tony Stone

  • Sr. Member
  • ****
  • Posts: 280
Re: Source Editor - Open Source Folder Option
« Reply #16 on: January 28, 2025, 02:19:02 am »
Lol at the "...the windows 10 experience"


I have not tested.  It should not be a white background.  I had a little background color issue myself. Some how the statusbar is painted a slightly different grey in my system even when I set the brush color to the statusbar color the grey on my system is wrong.  It is an issue I wanted to discuss but I think it was opening a can of worms.


Again this was just me toying around with and experimenting with improving(butchering in my case) the IDE.  But I think it does show what I envision.


Today I played around with it some more and I have a pretty cool utility function now for truncating any string and fittings it on any canvas and it takes options to clip the begining end of middle and let's you set your indicator characters to show what has been clipped. So if ... Was no good or you wanted 4 periods you can set that. I'll share that snippet here later because it may be handy.


Also I did some testing on the open system file manager function and select a file.  I think as recommended that can be a separate function in something else because it can be very re useable.  As a matter of fact I'm putting the function in one of my other programs.


I know we don't want to clutter or make things look messy but I agree a folder 📂 icon may not be appropriate.  Although I can't think of a better image to use.


I did look at some other editors and really I think the editor looks a tiny bit cooler/speaker with some color down in the status bar... Even looks more modern when it shows the stop button for the macro recording. 


So while space down there is precious adding some icons is a super simple way to give it a slightly more modern look...




Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12399
  • Debugger - SynEdit - and more
    • wiki
Re: Source Editor - Open Source Folder Option
« Reply #17 on: January 28, 2025, 10:46:31 am »
I am still reflecting what the best visualization is.

Personally, I strongly feel that in its default state (no mouse over) it should not distract. Therefore have no indication. But anyone who feels that would be best, please voice your opinion.

The other options are, on mouse over:

- highlight (speed button style) => only one other app does that (as far as I have found)
- change cursor. Most likely "Hand" (like over links)
- Hint
- Display an extra panel at the far right, with a question mark, that open a help for the gutter
  (this last one can be on mouse over, or always / but I feel it would be better on mouse over / over any part of the gutter)

Action can be on single or double click.

By default the following elements exist:

- Line number => opens Goto line dlg
- Status (modified, read only, ...) => no action
- INS/OVR => no action
- Editor Macro recording indicator (red stop button) => single click to stop recording
- File name => opens OS file browser

Pros and Cons.

Make all single click
+ unify behaviour
+ Most indicators work better (or only) with single click
- Easier accidental click
- Unexpected to those already using the feature

Mouse pointer / Highlight
+ minimum effect
+ highlight could even be delayed by a few milliseconds (so I feel that would be overkill)

Hint
- Delayed reaction, may be less easy to discover
+ Could display additional info (and along side the text "[double ]click to ..."
  (e.g. if filename does not fit / size on disk / explanation of INS/OVR )
~ Would work with double click



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12399
  • Debugger - SynEdit - and more
    • wiki
Re: Source Editor - Open Source Folder Option
« Reply #18 on: January 28, 2025, 10:47:52 am »
I had a little background color issue myself. Some how the statusbar is painted a slightly different grey in my system even when I set the brush color to the statusbar color the grey on my system is wrong.  It is an issue I wanted to discuss but I think it was opening a can of worms.

SysColorToRGB ? or similar...

But ideally avoid custom pant (for text panels)

Tony Stone

  • Sr. Member
  • ****
  • Posts: 280
Re: Source Editor - Open Source Folder Option
« Reply #19 on: January 28, 2025, 05:55:09 pm »
I am still reflecting what the best visualization is.
....  But anyone who feels that would be best, please voice your opinion.

I would love to see others opinions as well.  Just had the thought.  MAYBE(im at work cant experiment) having the mouse move over the text and it underlines just the path and changes to the hand point would be a strong indicator of what clicking it will do.  But as I imagine it underlining only the path(- filename) it may look look a bug by not underlining the entire path.

I did look at various text editors and I did like how Visual Studio Code had things on the status bar.  It looked sort of nice.

As far as your concern on accidental clicks I am not so sure that is a big concern because it is not really at the corners.  I suppose if you try to resize the window from the middle there is potential for an accidental click however that still doesnt concern me a lot because there is many places where we can have inconsequential accidental clicks. 

I think in my tests I also needed to compensate for the canvas size not accounting for the bevel of the status panel which made it look incorrect.  But again I don't expect my code is what would actually be used...

I think I mentioned earlier but at the very least I think it should without a doubt be added to the context menu of the tab because I automatically checked there for the option in the past.  So that would be most logical and I think n7800 agreed.  At least in the context menu the only things to consider would be where in the menu and the appropriate caption.

As far as hints.... I am not so sure I ever looked for hints in a statusbar.  Something about hints in a statusbar feels wrong to me.

So many things to think about for a simple feature. hmmm

440bx

  • Hero Member
  • *****
  • Posts: 6528
Re: Source Editor - Open Source Folder Option
« Reply #20 on: January 28, 2025, 09:28:42 pm »
I would love to see others opinions as well.
I think the presence of a visual and _discrete_ indicator is desirable.  The little "open folder" looks reasonable to me.

As it currently is, there is  no indication that right clicking on the filename and/or the line/column numbers combination opens a popup menu option.  They look the same as the INS/OVR indicator which does not offer a popup menu.

IOW, without an indicator of some kind, determining if there are additional options is a guessing game.  I believe such guessing games should be avoided whenever reasonably possible.

FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

n7800

  • Hero Member
  • *****
  • Posts: 709
  • Lazarus IDE contributor
    • GitLab profile
Re: Source Editor - Open Source Folder Option
« Reply #21 on: January 28, 2025, 11:16:19 pm »
In general, we are discussing several features here at once, each independently:
  • Highlighting of clickable panels when hovering
  • New function for opening a file and selecting
  • New function for shortening the path by canvas width

Hints in the status bar can be discussed elsewhere (for example, in my future MR), so as not to overload the topic.

I don't have much time for Lazarus in the near future, here is part of my review. There are a lot of points, but don't be scared, it's normal ))

n7800

  • Hero Member
  • *****
  • Posts: 709
  • Lazarus IDE contributor
    • GitLab profile
Re: Source Editor - Open Source Folder Option
« Reply #22 on: January 28, 2025, 11:29:51 pm »
About a separate icon:

* It would be better if you could click anywhere in the panel, not just a small icon. This would make the function more visible and easier to click. Accidental clicks are not excluded, but they will not lead to anything terrible - the user will simply close an unnecessary folder.

* The icon takes up space in the status bar. I usually have two editors open side by side, so only half the screen is left for it. If the IDE is open on a laptop, the width is even smaller.

* UTF symbols are too system (font) dependent. At first they were displayed as two questions for me (it seems that the merge program changed it), and after applying a patch via "pure" git, a square is displayed.

* A simple icon does not indicate that it is clickable (e.g. I never thought that the macro icon was clickable). For this, it should look like a button (with borders, background). But this will make the status bar look like a toolbar.

Sorry for such "critique". I also think that the icon looks nice, but for a decorative element there are too many minuses. And the advantage of not having an icon is that the implementation is simplified by a dozen lines ))

I still think that changing the cursor and highlighting the text (underlining) on ​​mouse hover is enough. Everyone has a web browser, and this is very intuitive.

n7800

  • Hero Member
  • *****
  • Posts: 709
  • Lazarus IDE contributor
    • GitLab profile
Re: Source Editor - Open Source Folder Option
« Reply #23 on: January 28, 2025, 11:42:43 pm »
Regarding single and double click

If the panel is highlighted when hovering over it with the mouse (especially if it is underlined, like a link), then a single click will be logical and even mandatory. Buttons never require a double click, and links even more so. For the same reason, the macro button does not require a double click.

Yes, this will change the behavior of the IDE, but it will be immediately noticeable even when hovering over it, before the click (I am sure that few people even knew about this function). A double click will not lead to anything terrible, as with an accidental click - the user will simply close an unnecessary folder.

n7800

  • Hero Member
  • *****
  • Posts: 709
  • Lazarus IDE contributor
    • GitLab profile
Re: Source Editor - Open Source Folder Option
« Reply #24 on: January 28, 2025, 11:52:38 pm »
About the code

* As far as I can see, the background when entering StatusBarDrawPanel is already filled, and FillRect is not needed. On the contrary, need to set AStatusBar.Canvas.Brush.Style:=bsClear; so that the text is drawn without a background. It works in Windows, check it on your OS.

* I'm not sure about the vertical position of the text. I see that it is shifted by 1-2 pixels. I haven't looked deeply into the code yet, and I still need to check how it looks on other widget sets. I hope someone will do it, because I currently do not have enough disk memory for virtual machines.

* If the entire panel is clickable, then the all code in StatusBarMouseMove can literally be replaced with one line:
Code: Pascal  [Select][+][-]
  1. StatusBar.Cursor := IfThen(StatusBar.GetPanelIndexAt(X, Y) = CStatusPanelFile, crHandPoint, crDefault);
  2.  

n7800

  • Hero Member
  • *****
  • Posts: 709
  • Lazarus IDE contributor
    • GitLab profile
Re: Source Editor - Open Source Folder Option
« Reply #25 on: January 29, 2025, 12:09:13 am »
Function to shorten path by canvas width

Today I played around with it some more and I have a pretty cool utility function now for truncating any string and fittings it on any canvas and it takes options to clip the begining end of middle and let's you set your indicator characters to show what has been clipped. So if ... Was no good or you wanted 4 periods you can set that. I'll share that snippet here later because it may be handy.

I also wanted to be able to control the number of fixed components on the left and right. Depending on the purpose of use, there may be different requirements. And perhaps for the status bar in the editor, the left part has priority, since the file name can be read in the tab title. I often need to see which folder of the disk root I am in.

Note that ShortDisplayFilename always displays 2 components of the path on the left. The function can also be made configurable by adding default parameters. Then your overload will be fully compatible with it (except for the extra TCanvas argument, and specifying aLimit in pixels instead of characters).

Tony Stone

  • Sr. Member
  • ****
  • Posts: 280
Re: Source Editor - Open Source Folder Option
« Reply #26 on: January 29, 2025, 12:25:42 am »
Function to shorten path by canvas width
I actually started working on a rewrite of that path shortening function with some options.  I have 2 issues I am working through with it and I will share it here.  I think it is a slick block of code to shorten a path or anything to fit in a canvas.

I still think that changing the cursor and highlighting the text (underlining) on ​​mouse hover is enough. Everyone has a web browser, and this is very intuitive.
I agree, acting like a link would be very intutive and expected to me.  But again I really like the icon look which as you mention a UTF8 character is probably no appropriate for production.  So an image is just adding complexity we dont need for something so simple.  IMO.

IOW, without an indicator of some kind, determining if there are additional options is a guessing game.  I believe such guessing games should be avoided whenever reasonably possible.

Yeah really feel there needs to be some indicator.  I didn't even know I could double click the line numbers to go to a specific line until I started playing in the sourceeditor code!  So I may not be a real programmer but I am normally pretty good at finding my way through a GUI in many programs.  So I think for sure there needs to be some sort of a visual indication that there is functionality "hidden" down there.

And I don't think I am too scared or offended by the critique.  :)   I  am having  a lot of fun doing this.  I am a little afraid to show my code some times though lol. (so my first round to truncate the path in the middle I was using a stringlist for each character... iterating and removing etc...  :-[ .... but yeah... i had a working mess and made it more proper with a little more research)


Tony Stone

  • Sr. Member
  • ****
  • Posts: 280
Re: Source Editor - Open Source Folder Option
« Reply #27 on: January 29, 2025, 12:35:18 am »
Function to shorten path by canvas width

I also wanted to be able to control the number of fixed components on the left and right. Depending on the purpose of use, there may be different requirements. And perhaps for the status bar in the editor, the left part has priority, since the file name can be read in the tab title. I often need to see which folder of the disk root I am in.

For an exercise I will mess around and see if I can make a simple and clean version that lets you choose a priority side.  Sounds like that is getting even more complicated!  I already put 10 times more hours into this 20 line function than it would take some one else.  But I will mess with that idea tonight.  I think you are right though as you said earlier this turned into separate issues.  I think I have an idea how to do that.  When I started writing it I thought it was super simple but as it unfolded into a working function I began getting many more concerns like which half to trim(left or right)... then began thinking if it is enough to display the entire file name should it just display the entire file name.  Then what happens when there isnt even enough room for that.  So as I am sure you know... the simplest ideas end up having a lot of seperate cases to handle. 

n7800

  • Hero Member
  • *****
  • Posts: 709
  • Lazarus IDE contributor
    • GitLab profile
Re: Source Editor - Open Source Folder Option
« Reply #28 on: January 29, 2025, 12:54:44 am »
I have several dozen patches that work in 95% of cases. But they cannot be published until the remaining 5% of edge cases are processed, and this requires a lot of work. Very frustrating. But fortunately there is no hurry ))

n7800

  • Hero Member
  • *****
  • Posts: 709
  • Lazarus IDE contributor
    • GitLab profile
Re: Source Editor - Open Source Folder Option
« Reply #29 on: January 29, 2025, 12:59:01 am »
About the function for opening a file in a folder

I was just looking at making a OpenAndSelect function that could be useful elsewhere.  I did not test on any system other than my Linux Mint system so it would need to be tested on other systems.

I am sure that in Linux every file manager should show help -h. It is enough to read it and make sure that the parameters are correct.

Unfortunately explorer.exe in Windows does not give any help with any parameter (-? -h /? /h /help), but there is an archived article on the Mircosoft website. I have been using its parameter /select, for a long time, and it definitely works in Windows 7/8. It is strange that the comma after the parameter is required...

After checking the help of file managers, you can suggest this function on the bug tracker, where developers on other platforms will check it and leave a review. For example, I am not sure, but /expand for explorer can be useful. And probably it is better to explicitly specify the extension .exe for it.

About the code:

* You accidentally specified /bin/sh in TProcess for all platforms, so the folder does not open on Windows. It is better to use the full command line for each variant and pass it "AProcess.CommandLine := FileManagerCmd;"

* All {$IFDEF} should be converted to {$IF}/{$ELSEIF} and {$ELSE} for other platforms, since the FileManagerCmd variable is not even initialized for them now. For them, you can simply call OpenDocument for the parent folder. Please note the example of correct use of directives.

* The "if not FileExists(SourceFilePath) then" check doesn't always work. The file may be virtual (not yet saved by the project), but the old file may exist on disk. Hopefully Martin will tell you the correct way to check, as this is not my area of ​​expertise.

* "OpenAndSelect"? I can suggest the names "OpenInFolder", "SelectInFolder".

 

TinyPortal © 2005-2018