Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: killerbot on October 07, 2009, 09:53:32 pm

Title: read only
Post by: killerbot on October 07, 2009, 09:53:32 pm
I was wondering with the latest changes wrt scintilla, the engine beneath our 'editor' tabs, which are files being opened.
Is the following quick to implement or modify.

When you open a read only file, you can not edit in CB, several editors allow editing and upon saving then tell it is read only, allowing you to force it to make readable, other sometimes ask you to force it writable at the moment of the first modification.

I think it would have added value to have this possibility in CB, so we don't need to leave CB to manually adjust the r/w flag.

Even when there are version control systems that make their files read only so you have to isse an explicit check out command, this still will have added value, I think.

Any comments, suggestions ?
Title: Re: read only
Post by: daniloz on December 16, 2010, 01:58:32 pm
Hi killerbot,

Any news on this feature request ?

I am asking because I was thinking about implementing it, but first would like to be aware of the current status (anyone working on it?, etc...)
Title: Re: read only
Post by: oBFusCATed on December 16, 2010, 02:41:09 pm
If I remember correctly Morten has done something related to ReadOnly files, I don't remember exactly what.
There was an old topic, where someone (Morten I think) had arguments against such feature.
Title: Re: read only
Post by: daniloz on December 16, 2010, 02:45:14 pm
@oBFusCATed:

I am talking to Morten about it already, thank you...
Title: Re: read only
Post by: Jenna on December 16, 2010, 03:18:23 pm
Just for the record, the file properties have a checkbox to set or unset the readonly status.
Title: Re: read only
Post by: daniloz on December 16, 2010, 03:26:17 pm
@jens:

I am aware of that one and like it very much. However, the point is, if a file is already open and is read-only, then even after you go there and uncheck the Read-only attribute, you cannot edit the file. You have the close it and open again...

So, my first though was that the file status should be refresh after a change in the read-only checkbox... and all diverged to a more general discussion...

Thank you for taking me back to my initial point. Maybe this should be the first step in the implementation, a callback to whatever-is-needed-to-refresh-the-editor-read-only-attribute, so after the file properties dialog is closed, you can edit the file...
Title: Re: read only
Post by: killerbot on December 16, 2010, 07:13:19 pm
wrt read only, there another issue to. I think when you go to the properties of a file, and exclude if from compile/link, then the checkbox of readonly gets active, and one has to ,manually remove the readonly attribute.

Dunno, about the reloading, but if that does not happen automatically, I think it should .Closing and opening a file, that's so windows like ;-)
Title: Re: read only
Post by: daniloz on December 16, 2010, 08:29:59 pm
wrt read only, there another issue to. I think when you go to the properties of a file, and exclude if from compile/link, then the checkbox of readonly gets active, and one has to ,manually remove the readonly attribute.
When I look into the auto-reloading for read-only, I'll have a look at it as well...


Dunno, about the reloading, but if that does not happen automatically, I think it should .Closing and opening a file, that's so windows like ;-)
I am not 100% sure (and I don't have C::B available right now), but I think if you change the read-only attribute externally  (using TotalComander ;-), for example), then you can just switch to C::B ans start typing. BUT, if you use the file properties dialog inside C::B to untick the read-only, then you have to open and close the file in oder that the change is taken...

But anyway, I agree, that's so windows like :-p (btw, anyone - maybe jens - can report what's the behavior on *nix systems?)

@all:
I am still making my way through the source code, scintilla, wxwidgets and so on... so any hints about how the read-only attribute is treated (which class, updates etc..) would be MUCH appreciated... :-)
Title: Re: read only
Post by: MortenMacFly on December 18, 2010, 01:52:11 pm
I am talking to Morten about it already, thank you...
an I am aware that I still have the task to create the patch. Hence time is limited atm... but it's not forgotten. Sorry.  :(
Title: Re: read only
Post by: daniloz on December 18, 2010, 02:54:20 pm
an I am aware that I still have the task to create the patch. Hence time is limited atm... but it's not forgotten. Sorry.  :(
No problemo... My time is still limited, so I can still say that I'm not working on this issue because I don't have the patch from you... :-)
Title: Re: read only
Post by: MortenMacFly on December 27, 2010, 05:06:33 pm
an I am aware that I still have the task to create the patch.
Here it comes (finally).

Not 100% working, but at least better than the current state.

Notice the following things in general (which makes things complicated btw):

Patch is attached... not implementing the above. ;-)
Title: Re: read only
Post by: daniloz on January 03, 2011, 10:42:25 am
Here it comes (finally).
Ok, thank you!!! I've downloaded it and will have a look... I let you know...
Title: Re: read only
Post by: daniloz on January 29, 2011, 07:15:23 pm
@jens:

I am aware of that one and like it very much. However, the point is, if a file is already open and is read-only, then even after you go there and uncheck the Read-only attribute, you cannot edit the file. You have the close it and open again...

So, my first though was that the file status should be refresh after a change in the read-only checkbox... and all diverged to a more general discussion...

Thank you for taking me back to my initial point. Maybe this should be the first step in the implementation, a callback to whatever-is-needed-to-refresh-the-editor-read-only-attribute, so after the file properties dialog is closed, you can edit the file...

I finally manage to get some time to look into this issue and, actually, there's a very simple way to do the refreshing, by using the CheckForExternallyModifiedFiles() from the EditorManager... The patch is attached, please feel free to test it... :-)

Expected behavior: when you right-click on a tab or file, go to "Properties..." and then change the "File is Read-Only" flag, the editor is refreshed automatically to reflect the new flag.

Old (actual trunk) behavior: The editor is only refreshed and reflect the new Read-Only state after you trigger a CheckForExternallyModifiedFiles(), either by closing it and opening again or by clicking outside C::B and coming back, so it regains the focus (on Windows)