Author Topic: modifying read-only files in diffzilla  (Read 4618 times)

cdouble

  • Community Member
  • Posts: 43
  • Hero Points: 0
modifying read-only files in diffzilla
« on: March 31, 2008, 05:21:29 PM »
I was disappointed to see that this didn't make the cut for 2008.

http://community.slickedit.com/index.php?topic=2265.0

So how tough would this be to implement myself? I MUST have the ability to modify files (even if they are read-only) during a diff. Closing the diff and restarting is okay if you have 100 files but I have 10,000 and this is way too slow.

Any pointers on how to implement this feature (or any workaround) would be much appreciated.

Thanks,

CD

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: modifying read-only files in diffzilla
« Reply #1 on: April 01, 2008, 02:17:35 AM »
[Oops, originally clicked on the wrong Reply button in the Recent Posts view; found and moved the post to here where it belonged]

This is one of the next few things on my priority list of tweaks to make for my own use, but I haven't yet begun.
I expect it to go something like this:

1.  Start in diffedit.e and look for places that check p_readonly_mode.  Many of them should check _QReadOnly() instead.
2.  It looks like there are several places in the stock SE macros that check p_readonly_mode when they should check _QReadOnly(), so maybe some additional macros outside the diff ones will need to be updated as well.  (For example, the Clipboards toolbar refuses to paste into readonly windows, and also frequently says "Unable to get clipboard data" when I double click, but I don't know yet if the second is a side effect of the first).
3.  Compile a list of the ones I think are erroneous, and submit the list to the SlickTeam for evaluation and possible inclusion in a future update.

cdouble

  • Community Member
  • Posts: 43
  • Hero Points: 0
Re: modifying read-only files in diffzilla
« Reply #2 on: April 01, 2008, 07:19:30 AM »
Sounds good. I hacked up diff.e and the function DiffSetupWindows today just to see. That may not seem like a fix but it allows me to change the read-only properties (like check the file out) underneath while i'm in the diff. It complains about the file being read-only until i check it out and ideally, i'd want the file writing to bring up the read-only file dialog box which lets me check the file out but for now this kluge works.

I changed these lines in DiffSetupWindows:

   editorctl_wid.p_readonly_mode = VSPROTECTREADONLYMODE_OPTIONAL;

   _SetDialogInfo(id,editorctl_wid.p_buf_id' 'inmem' 'editorctl_wid.p_readonly_mode,_ctlfile1);

   readonly_wid.p_value=(int)VSPROTECTREADONLYMODE_OPTIONAL;
   editorctl_wid.p_ProtectReadOnlyMode= VSPROTECTREADONLYMODE_OPTIONAL;
   readonly_wid.p_enabled=!readonly_wid.p_value;


I think the behavior i'd like to really see, is that there's a button the diff dialog box after a multi-directory compare that asks me if i'd like to checkout all of the "changed" target files in the diff. I could also live with a single file checkout too but that's a bit more tedious.

Thanks,

CD

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: modifying read-only files in diffzilla
« Reply #3 on: April 01, 2008, 06:51:17 PM »
First, a few observations about that change, and then I'll suggest a different change:


   editorctl_wid.p_readonly_mode = VSPROTECTREADONLYMODE_OPTIONAL;
// p_readonly_mode is boolean, so the line above is no different than
// setting it to true.


   readonly_wid.p_value=(int)VSPROTECTREADONLYMODE_OPTIONAL;
// readonly_wid.p_style is PSCH_AUTO2STATE, so the line above is no different
// than setting it to 1.  As a quick hack, you may want to simply set it to 0
// so the file is not treated as readonly.  A more involved change might make
// the checkbox PSCH_AUTO3STATEB when _default_option('Z') (the
// "Protect readonly mode" option) is true, and set the p_value to 2 (the
// solid/gray state for a tristate checkbox), and check everyplace that
// checks readonly_wid.p_value to recognize it as a tristate checkbox and
// treat both 2 and 0 as "not readonly".


   editorctl_wid.p_ProtectReadOnlyMode= VSPROTECTREADONLYMODE_OPTIONAL;
// This line is the one that actually had an effect, but look at the
// _ctlfile1_readonly.lbutton_up() handler in diffedit.e.  When you
// check/uncheck the ReadOnly checkbox it will go back to enforcing
// readonly mode again.  Maybe that's what you're going for, but when
// I set "Protect readonly mode" to false, I mean that I want to be
// able to edit readonly files, and I just want to get prompted when
// I go to save them.



After having poked at this a bit, I've had more success with the following change to diffedit.e, instead.  My goal was to make Diffzilla allow modifying readonly buffers when "Protect readonly mode" is false, and as far as I've been able to tell so far, it seems to accomplish that:

diffedit.e, circa line 2637 in the SE 2008 revision of the file:
Code: [Select]
static boolean DiffEditorIsReadOnly()
{
   if ( _DiffGetReadOnlyCBMissing()==1 ) {
      boolean isro=_DiffGetReadOnly()==1;
      return(isro);
   }
   int readonly_cb_wid=p_name=='_ctlfile1'?_ctlfile1_readonly:_ctlfile2_readonly;
   return(readonly_cb_wid.p_value!=0
          // chrisant: Don't enforce readonly mode when the "Protect
          // readonly mode" option is off.
          && _default_option('Z'));
}