Recent

Author Topic: Feature request/suggestion about file saving  (Read 2859 times)

440bx

  • Hero Member
  • *****
  • Posts: 4478
Feature request/suggestion about file saving
« on: July 27, 2024, 04:39:30 am »
Hello,

It would be nice to be able to configure Lazarus to automatically save any file that has been modified when it loses focus (that is, the user is switching to another app.)

That would enable the other app to detect any changes that were made to the files using Lazarus.

Comments welcome.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7454
Re: Feature request/suggestion about file saving
« Reply #1 on: July 27, 2024, 09:29:26 am »
Two thoughts:

i) Does Lazarus save files (or make temporary copies) when it gets a power-failure signal?

ii) Could automatic saving be handled by an IDE plugin?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

440bx

  • Hero Member
  • *****
  • Posts: 4478
Re: Feature request/suggestion about file saving
« Reply #2 on: July 27, 2024, 10:16:37 am »
I don't know the answers to those two questions but, I am under the impression that there is no plugin support in Lazarus.  Is that impression incorrect ?
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7454
Re: Feature request/suggestion about file saving
« Reply #3 on: July 27, 2024, 10:57:03 am »
I don't know the answers to those two questions but, I am under the impression that there is no plugin support in Lazarus.  Is that impression incorrect ?

OK, "compiled-in package" then. Poor terminology on my part.

In this particular case I can't speak for Linux (or other unices), but my experience is that Windows handles the "SHUT DOWN NOW" triggered by e.g. a UPS fairly well.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

DomingoGP

  • Jr. Member
  • **
  • Posts: 69
Re: Feature request/suggestion about file saving
« Reply #4 on: July 27, 2024, 03:10:33 pm »
Quote
ii) Could automatic saving be handled by an IDE plugin?

Hi, the attached zip contains a barely tested ide plugin that save the files when the ide is deactivated.

I hope it solves your feature request.

How to use:
Menu -> Package -> Open package file (lpk).
Button Compile
Button Use/Install.

If you don't like it  :( then:
Open package file (lpk)
Button Use/Uninstall.

Regards
Domingo.

440bx

  • Hero Member
  • *****
  • Posts: 4478
Re: Feature request/suggestion about file saving
« Reply #5 on: July 27, 2024, 03:41:57 pm »
Domingo,

Thank you very much.

It works but not quite the way it should work.  For some reason when switching, Lazarus does save the file but, it takes several seconds and multiple switchings before my editor sees the changes in the file.

That does not happen when using the normal "Save" (ctrl_s) or "Save all".  When using "Save"/"Save all"/"Ctrl-s" my editor sees the changes instantly.

As strange as it may sound, it looks like the line:
Code: Pascal  [Select][+][-]
  1.   LazarusIDE.DoSaveAll([]);
is not equivalent to manually doing a "Save all" or "Save".

The problem I described above occurs when switching from Lazarus directly to my editor. 

Strangely, if I switch back to my editor by clicking on my editor's icon on the taskbar then the changes appear immediately.

Summary: when switching directly something isn't quite right, it looks like the file's modified date and time are not updated immediately.  when switching by means of the taskbar then the changes appear immediately.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

DomingoGP

  • Jr. Member
  • **
  • Posts: 69
Re: Feature request/suggestion about file saving
« Reply #6 on: July 27, 2024, 04:58:43 pm »
I think that the problem is in the sequence of events.

Your Editor becomes active and checks for changed files before lazarus becomes inactive and saves the files, whereas saving in the IDE ‘Save all’ saves the files and when your editor becomes active it detects the changes.

Changing using taskbar: TaskBar becomes active, lazarus becomes inactive and save the files,  taskbar becomes inactive, editor becomes active and see the changes.

Right now I have no idea how to fix it, sorry.

440bx

  • Hero Member
  • *****
  • Posts: 4478
Re: Feature request/suggestion about file saving
« Reply #7 on: July 27, 2024, 08:20:28 pm »
Right now I have no idea how to fix it, sorry.
That's fine.  I appreciate your efforts and switching using the taskbar is just a small extra step, no big deal.

Thank you again.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4515
  • I like bugs.
Re: Feature request/suggestion about file saving
« Reply #8 on: July 28, 2024, 09:57:45 am »
... and switching using the taskbar is just a small extra step, no big deal.
Yes, using the OS taskbar or using the "Save All" button in Lazarus main window coolbar or the same button placed in the editor toolbar.
They all require just one click.

I am a little curious why you want to use another editor. Programming is not only writing code but also studying existing code and IMO Lazarus editor is very good for that. You can quickly jump to definitions and ancestors etc. and then back. The integrated help system is rather good, too.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Joanna

  • Hero Member
  • *****
  • Posts: 988
Re: Feature request/suggestion about file saving
« Reply #9 on: July 28, 2024, 05:08:35 pm »
I’m also curious about the desire to save file everytime focus is lost.
It’s easy to save all . If you are using a computer without battery backup  and your concern is a sudden power outage wouldn’t you also want to save work every minute or something? I vaguely remember word processors doing this.
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

440bx

  • Hero Member
  • *****
  • Posts: 4478
Re: Feature request/suggestion about file saving
« Reply #10 on: July 28, 2024, 05:54:43 pm »
I am a little curious why you want to use another editor. Programming is not only writing code but also studying existing code and IMO Lazarus editor is very good for that. You can quickly jump to definitions and ancestors etc. and then back. The integrated help system is rather good, too.
It's difficult to show why I prefer the editor I use over any other editor (not just Lazarus'.)

Lazarus' editor is reasonably good, take that as high praise because I consider the majority of editors out there as being unfit for text editing.

As far as the facilities that Lazarus provides, such as function definition hints and code navigation, I completely agree that those are great but, the problem I face is they stop working as the code gets more complex.  Codetools doesn't seem to handle the way I structure code.  In the project I'm working on currently I cannot get function definition hints, jumping to function definitions/implementation does not work, code completion does not work, hints (if and when they appear, which is unusual) are sometimes yellow and sometimes grey, they grey ones are a pain because it's not possible to scroll them causing them to rarely show the information that is of interest.  The only feature that causes me to do _some_ editing in Lazarus is that I can edit while debugging and _that_ is occasionally extremely convenient (and obviously a feature I cannot get from a "text editing only" editor such as the one I use.)

It is not an exaggeration to state that I edit, at least, 10 times faster using Multi-Edit (the editor I use) than any other editor including the Lazarus editor (which I consider to be usable - again, that's high praise)

Having Lazarus save the files when I switch back to my editor is great.  Also great is that Lazarus detects and reloads the file when it has been modified by an external tool (that feature is pure gold.)

You may be wondering why I don't report these bugs.  The reason is, they normally start happening after the program has grown to be of "some size".  That makes it difficult to create a short program that exhibits the problem(s) because I don't know what in the code is causing the problem(s).

There reasons I use Lazarus are two: 

1. it's an excellent front end to FPC. 
2. FpDebug is a debugging jewel.

and when/while it works the codetools facilities (code completion, code "exploration", hints) but, I cannot list that as a reason because those features eventually eventually stop working (which I have to admit, is a bit frustrating.)



« Last Edit: July 28, 2024, 06:03:04 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Joanna

  • Hero Member
  • *****
  • Posts: 988
Re: Feature request/suggestion about file saving
« Reply #11 on: July 28, 2024, 06:01:17 pm »
It’s very seldom that I save a file in Lazarus because the files are saved automatically everytime I compile which I do a lot.
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10235
  • Debugger - SynEdit - and more
    • wiki
Re: Feature request/suggestion about file saving
« Reply #12 on: July 28, 2024, 06:24:14 pm »
If I may, I would like to join in on the editor part. And specifically with questions towards 440bx.

Let me start with, I am not trying to convince you of anything. And I know that even between 2 editors with equal features, the one that has been used in the past will be preferable (And if only due to the exact key combos, some layout diff ....). So to switch to another editor it does have to be more than equal.

That said, if Lazarus has any features deemed missing, I will point that out. At least for educational purposes. If it is missing some, I may (at my leisure) consider, if I would find it interesting to add them. (no promise there, and again, I understand that even if they were added, that would not necessary change your preferences).

So, I am still interested in what (if any) the difference are?
- Any features (such as navigation, modifications, ...) available (or available in less keystrokes)?
- Any display features (such as highlight, wordbreak, margin indicators...)
- Management: arrangement of tabs, switching, overviews (files, content), menu, ....
- Just more convenient key combos?
- ...

« Last Edit: July 28, 2024, 08:12:47 pm by Martin_fr »

440bx

  • Hero Member
  • *****
  • Posts: 4478
Re: Feature request/suggestion about file saving
« Reply #13 on: July 28, 2024, 08:52:05 pm »
@Martin,

One of the characteristics that make the editor I use much more efficient to use is that it does _not_ use control keys.  It may sound strange but the control key might very well be the most difficult and inconvenient key to reach in the keyboard, that makes its use highly inefficient (and consequently undesirable.)  The editor I use is more function-key centric (function keys combined with mostly shift and alt - more WordPerfect-like than Wordstar-like.)

The ability to change the key mappings is great and I've used it to make the Lazarus editor use the same keys for some functions as my editor but, unfortunately that is limited by the fact that Lazarus implements a lot of other features which use key mappings that I would normally use for text editing.  That makes those key combinations unavailable for editing.  That's one general problem, which likely has no ideal solution.

After that, a lot of subtleties that, at first seem insignificant but make a noticeable difference.  The following is going to sound unreasonable but, I find that the speed at which the cursor moves left and right barely adequate (actually, that part is faster in Lazarus than in the majority of editors out there - I suspect the cursor/caret movement is done in software which is why it's faster than in most other editors), I estimate it's half the speed of ME (Multi-Edit, the editor I use.)  Moving the cursor vertically (up/down) is paintfully slow particularly when it has to scroll the window at the same time. That's probably somewhere between 1/8 to 1/4 (at best) the speed of ME.  When I need to scroll more than a few lines, I switch back to ME, it takes less time to switch back and do what I need there than scrolling to the line of interest in Lazarus. 

It's amazing how small details can make a big difference.  When I bookmark something in ME and "retrieve" the bookmark, what is shown in the window is _exactly_ what was there when I set the bookmark.  That means, the top line is what it was when I set the bookmark, the cursor is in exactly the same place.  This means that, when I retrieve the bookmark, I don't have to get acquainted with what's displayed because it is exactly the same as what was there when the bookmark was set.  (strangely bookmark setting in ME is one of the few functions that is control-key driven.)

What makes an editor good is the combination of the features it supports, how they are implemented (which determines if they are fast or slow) and how they are managed (how do you "reach" them.)  Those are the characteristics that make the VS editor a total disgrace and most other editors, literally, intellectually painful to use.

Considering that the Lazarus editor has to inhabit the Lazarus IDE and, therefore share the environment (key mappings among other things) with other functionality, it is remarkably good.

As far as "wishing for a feature upon a star", I'd like to see retrieving a bookmark cause what's displayed in the window to be _exactly_ what it was when the bookmark was set, meaning top line , cursor position, everything.  (I've already made a feature request for that, this is just to let it be known that I still wish for that.)

Thank you for reading.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10235
  • Debugger - SynEdit - and more
    • wiki
Re: Feature request/suggestion about file saving
« Reply #14 on: July 28, 2024, 09:09:18 pm »
The caret speed may come down to 2 things.

1) key repetition rate. Though that would be the same, an editor could instead register the down event, and start its own internal timer....
2) repaint.

Technically just moving the caret, does not repaint anything (its an xor paint of just the few pixels).
But SynEdit will likely redraw the current line. (Not checked), since often Highlights change (current word,...). Also it needs to check what may have changed.
Moving up down, changes display in the gutter, and so there also is a repaint. And it searches for the "top line hint / proc header". Probably other stuff too.


 

TinyPortal © 2005-2018