Author Topic: Set Initial Edit Window Size  (Read 11473 times)

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Set Initial Edit Window Size
« on: May 22, 2007, 01:31:02 PM »
A frequently requested SlickEdit feature is the ability to control the initial size of edit windows in the multiple-document interface.  I am one of those that wanted it and I have been involved in several discussions about it.

Macros have been submitted to try to achieve this.  I tried every one I saw, but had to abandon each after a short time because of unwanted behaviors.  One of the most promising was submitted almost a year ago by a SlickEdit employee, but it was overzealous and tried to resize everything.

I recently made a minor change to it and have been using it successfully for the last week.  Since I abandoned the other solutions within an hour, this is at least a partial success.

To use it, unzip it into a place where you keep macros and use Macro->Load Module... to start it up.

It is heavily commented so you should not have much trouble changing it to fit your style.

- Tim

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Set Initial Edit Window Size
« Reply #1 on: May 31, 2007, 12:26:58 PM »
This macro has a problem very similar to the one I thought I'd fixed: It tries to resize non-edit windows.  I guess I need to spend some more time on this.

- Tim

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: Set Initial Edit Window Size
« Reply #2 on: June 01, 2007, 11:36:10 AM »
I have been experiencing errors in the resize macro when I try to reload a file. Is there a way to detect that a file is being reloaded? If so I would not try to resize the window.

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Set Initial Edit Window Size
« Reply #3 on: June 01, 2007, 01:32:42 PM »
How are you reloading the file?

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: Set Initial Edit Window Size
« Reply #4 on: June 01, 2007, 01:57:14 PM »
I'm not doing it explicitly. The reload occurs when another application (source code manager) modifies the file while it is open in SE. When SE gets the focus it recognizes that the file has been modified and offers to reload it. If I say Yes, at that point the error occurs (sometimes but not always).

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Set Initial Edit Window Size
« Reply #5 on: June 01, 2007, 02:43:15 PM »
OK, thanks for the information.  When I get a chance I'll look into it.

alex

  • Community Member
  • Posts: 64
  • Hero Points: 6
Re: Set Initial Edit Window Size
« Reply #6 on: June 01, 2007, 02:50:47 PM »
If you get a stack trace, you can find the exact location that caused the problem:

From http://www.slickedit.com/images/stories/product_documentation/SlickC/slickcmacroconventionsandbestpracticesforendusers.pdf

"2. Typing st -f <offset> on the SlickEdit command line and pressing ENTER. Example: st -f 1438 with the test.e module open would put our cursor at the offending line in the my_test_macro function."

I had this exact problem you described on reloading the files using my own resizing macros, and I discovered it was because I was accessing a field of p_parent when it wasn't valid.  Perhaps it's something similar with resize.e accessing a property that isn't available.  The stacktrace should make it easy to find, if that's the problem.

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: Set Initial Edit Window Size
« Reply #7 on: June 01, 2007, 03:20:24 PM »
Well, I'm not referencing the p_parent field so it must be something else. Next time it happens I'll use the st command as you suggest.

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: Set Initial Edit Window Size
« Reply #8 on: June 07, 2007, 08:40:04 PM »
It appears that the property I'm referencing is p_font_width. This is the statement: col=width*p_font_width;

Any idea why it is not valid in this context? Is there a way to determine that the file is being reloaded?
« Last Edit: June 08, 2007, 09:17:03 PM by TxDot »

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: Set Initial Edit Window Size
« Reply #9 on: June 13, 2007, 06:54:15 PM »
Qualifying the property with _mdi.p_child seems to have resolved the issue. Interesting that the problem only occurred when reloading a file. Initial opening of a file always worked.

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Set Initial Edit Window Size
« Reply #10 on: June 14, 2007, 12:20:23 PM »
Here is a new version of the macro with the change suggested by TxDot.  I've been using it for about a day now and trying to get it to break.  A couple times a file opened and didn't get resized (i.e. it was still really wide.)  I haven't been able to replicate this, but I have no doubt that it will reoccur.  I haven't had any stack dumps.  I think that is a vast improvement.

It is not completely fixed, but it seems more healthy than the first version I posted here.  Many thanks to everyone.

- Tim

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: Set Initial Edit Window Size
« Reply #11 on: June 14, 2007, 02:42:41 PM »
Tim,
I have observed the same behavior a couple of times. I haven't identified a pattern yet but will post back if/when I do. The only think I can think that might have a bearing on it is that a docked window (probably build output) was open at the time this occurred. Well, I just tried that and it worked OK. Maybe something will begin to make sense.

JeffB

  • Senior Community Member
  • Posts: 326
  • Hero Points: 14
Re: Set Initial Edit Window Size
« Reply #12 on: June 14, 2007, 06:03:31 PM »
If I click on a function in the references window, so that a preview is loaded in the references "preview", then double click the the function to open the file, it doesn't get the new size.  If I have something else in the referenences "preview", then double click the function, the new size is applied to the window when it opens.

Perhaps you guys are seeing something similar ?

-Jeff

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Set Initial Edit Window Size
« Reply #13 on: June 15, 2007, 11:53:26 AM »
Thanks Jeff!  That may well be what I did when I saw it earlier.

- Tim