Author Topic: How do I get SlickEdit to create smaller windows  (Read 31547 times)

JeffB

  • Senior Community Member
  • Posts: 326
  • Hero Points: 14
Re: How do I get SlickEdit to create smaller windows
« Reply #15 on: June 12, 2007, 07:57:24 PM »
Clark,

I think Method 1 is the more generally useful option.

My ultimate desire (slightly off-topic) would be to have something like a mode where you could have X number of maximized windows (ie. X windows that equally fill the available space).  So that if there were 2 windows open, and the height of the toolbar on the bottom was increased, the size of both windows would decrease to fill the remaining space.  Decrease the width of a vertical toolbar, and the windows are adjust proportionately and equally to fill the remaining space.  One way to accomplish this would be to have more than one area for displaying windows...but I digress...

That goal in mind, for Method 1, an option to automatically use the available height (at the time the window is opened) would be nice.

A simple way to hook in a macro that would only get run for the correct window types would be very helpful. AFAIK, this doesn't exist today and would allow some flexibility.

-Jeff

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6879
  • Hero Points: 530
Re: How do I get SlickEdit to create smaller windows
« Reply #16 on: June 13, 2007, 02:29:34 PM »
My plan is to build this feature into the C++ code.  By the time the macro code is taking action it is too late.  I've already put together some test code and it seems flawless.

I'm going to start with the pixel method.  That way I'll be sure to get this feature into 12.0.2.  You're right though, it could be extended to support rows and columns for the fixed font case.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6879
  • Hero Points: 530
Re: How do I get SlickEdit to create smaller windows
« Reply #17 on: June 13, 2007, 02:35:17 PM »
Jeff, I missed your post (it was on the next page).  I like the idea of smarter tiling too.  I think it would be cool if you could specify the number of rows and columns for windows (i.e. 3 across, 2 down).  Also, autosizing tiled windows when the client area is changed (due to tool window size or MDI frame).  I already talked with one of the guys here about some of this.  I'll add this to our feature list.

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: How do I get SlickEdit to create smaller windows
« Reply #18 on: June 14, 2007, 11:30:46 AM »
Clark, I believe this should be part of the extension setup. I have extended my version of resize.e to size the buffer based on the file extension. For file extensions not specifically listed I don;t do anything so they open at the default size. I also use a fixed-width font and so I would prefer to specify column width. For height I would want the maximum. It seems to me that there needs to be several ways to specify both the width and the height. Maybe specifying an asterisk (or zero if you want to stay numeric) would mean "window maximum". 

BTW, thanks for working on this!

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: How do I get SlickEdit to create smaller windows
« Reply #19 on: June 14, 2007, 11:33:58 AM »
alex,

I'm using the resize.e macro that's been floating around for a while.  I've tried the original "_buffer_add_resize()" and "_buffer_add_set_new_window_size()".  Both cause an error (This property or method is not allowed on this object) when clicking on a function in the "references" listing the first time you do it.  I guess SlickEdit opens the file for previewing and hits the macro trying to move/resize it.

Do you not see errors under similar circumstances ?

-Jeff

Jeff, I also use a resize.e macro derived from the original I downloaded from here. However, I don't see the same error you're describing. I have had similar types of errors but I believe I have resolved them. Can you post your copy of resize.e so we can take a look and try it out to see if we get the same error?

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: How do I get SlickEdit to create smaller windows
« Reply #20 on: June 14, 2007, 11:43:38 AM »
Clark,

I think Method 1 is the more generally useful option.

My ultimate desire (slightly off-topic) would be to have something like a mode where you could have X number of maximized windows (ie. X windows that equally fill the available space).  So that if there were 2 windows open, and the height of the toolbar on the bottom was increased, the size of both windows would decrease to fill the remaining space.  Decrease the width of a vertical toolbar, and the windows are adjust proportionately and equally to fill the remaining space.  One way to accomplish this would be to have more than one area for displaying windows...but I digress...

That goal in mind, for Method 1, an option to automatically use the available height (at the time the window is opened) would be nice.

A simple way to hook in a macro that would only get run for the correct window types would be very helpful. AFAIK, this doesn't exist today and would allow some flexibility.

-Jeff

I think this sounds very useful. One question, what do you think should happen if a docked window is open (or closed) such as the build output window or the find results window? Should the height of the windows be decreased or left alone. I think it should be decreased. Here is an example of why I think that. When the build output window is visible and I do a find command, if the line where the text was found is under the docked window I can't see that. That means I have to use my mouse to move the lines into view. If the height of the window was decreased when the dockable window was opened the find command would have resulted in the window scrolling so that the text was visible.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6879
  • Hero Points: 530
Re: How do I get SlickEdit to create smaller windows
« Reply #21 on: June 14, 2007, 07:03:44 PM »
Here's what I've decided to do for a first pass.

I've chosen method 1 for simplicity.  I will add support for -hmax and -wmax options so you can always get the maximum height or width.  If a fixed width or height is given, I will make sure the window does not get clipped due to a smaller client area.  The windows will be created in a cascading manner.  I don't plan to attempt to automatically tile windows by finding free space.  I'm going to try to add a callback mechanism so the built-in logic can be thrown away. The callback will look something like this:

void _cbget_new_window_size(int &x,int &y,int &width,int &height)

x and y will be initialized to the values returned by the last call.
width and height will be initialized to the current maximum width and height of the client area. 

The newly created window will be at x, y, width,and height.

I'm pretty sure I can add a call back in this particular place in the C++ code.

Phil Barila

  • Senior Community Member
  • Posts: 745
  • Hero Points: 61
Re: How do I get SlickEdit to create smaller windows
« Reply #22 on: June 14, 2007, 08:46:19 PM »
Sounds like a really nice first cut at it.  I'm looking forward to seeing the results, whenever that might be...  :D

TxDot

  • Community Member
  • Posts: 38
  • Hero Points: 0
Re: How do I get SlickEdit to create smaller windows
« Reply #23 on: June 14, 2007, 09:29:23 PM »
Here's what I've decided to do for a first pass.

I've chosen method 1 for simplicity.  I will add support for -hmax and -wmax options so you can always get the maximum height or width.  If a fixed width or height is given, I will make sure the window does not get clipped due to a smaller client area.  The windows will be created in a cascading manner.  I don't plan to attempt to automatically tile windows by finding free space.  I'm going to try to add a callback mechanism so the built-in logic can be thrown away. The callback will look something like this:

void _cbget_new_window_size(int &x,int &y,int &width,int &height)

x and y will be initialized to the values returned by the last call.
width and height will be initialized to the current maximum width and height of the client area. 

The newly created window will be at x, y, width,and height.

I'm pretty sure I can add a call back in this particular place in the C++ code.
Sounds like a good start Clark. In my version of resize.e the windows cascade horizontally but not vertically. I like it this way. If I want the same behavior with your changes will I have to use the callback to set y to zero?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6879
  • Hero Points: 530
Re: How do I get SlickEdit to create smaller windows
« Reply #24 on: June 18, 2007, 02:04:02 PM »
Ok, here's what will be in 12.02.  I opted for a single command called new_window_size which allows you to configure the size of newly created windows.  It will be accessible from the Window menu since that seemed like the most logical place for it to go.

As a test, I wrote a sample callback which is a complete replacement for the C code which handles custom settings. If you want to enhance how the custom settings work, this will probably be helpful:

#include "slick.sh"
void _cbget_new_window_size(int &x,int &y,int &width,int &height) {
   /*
     Warning: p_window_id is set to the instance of the new window.  However,
     most window properties are not set yet.  This is because select_edit_mode
     has not been called yet.  The p_buf_name and p_buf_id are set.

     IMPORTANT: At the time of this call the system window (HWND or X Window)
     has NOT been created yet.  Therefore you can not do any font calculations
     against the current window.   Creating temp views does not help either
     because no system window is created. 

     Doing font calculations is not yet supported.  The #if zero'd code below
     is pretty close to getting the right font all the time.
   */
   // IF there are now previous values
   if (x<0) {
      x=0;y=0;  // Start at the top left corner.
   } else {
      // Choose some system metrics for cascading the windows.
      int adjust_x=GetSystemMetrics(VSM_CXVSCROLL)+GetSystemMetrics(VSM_CXDLGFRAME);
      int adjust_y=GetSystemMetrics(VSM_CYCAPTION)+GetSystemMetrics(VSM_CYDLGFRAME);
      x+=adjust_x;
      y+=adjust_y;
   }
   // A negative width or height means use as must space as possible.
   // No need to handle negative values here. Just return them.
   // No need to worry about with or height larger than client area.
   // This will be adjust if necessary later.
   width=_default_option(VSOPTION_NEW_WINDOW_WIDTH);
   height=_default_option(VSOPTION_NEW_WINDOW_HEIGHT);

#if 0
   int orig_wid=p_window_id;
   // Carefully use the hidden window
   _safe_hidden_window();

   // To attempt to determine whether this file is a SBCS/DBCS or
   // Unicode file,  jump through some hoops.  This code won't work
   // if the user overrided the default mode selection code.
   int temp_wid;
   boolean utf8;
   _create_temp_view(temp_wid,'',orig_wid.p_buf_name,true);
   utf8=p_UTF8;
   //say('utf8='utf8);
   _delete_temp_view(temp_wid);

   // This code assumes the font being used is for SBCS/DBCS mode source and
   // will not work for Unicode/Xml files.
   _str font_info=utf8?_default_font(CFG_UNICODE_SOURCE_WINDOW):_default_font(CFG_SBCS_DBCS_SOURCE_WINDOW);
   parse font_info with font_name ',' font_size ',' font_flags ','charset ',' ;
   if (!isinteger(charset)) charset=VSCHARSET_DEFAULT;
   p_redraw=0;
   p_font_name=font_name;p_font_size=font_size;
   p_font_bold=font_flags & F_BOLD;p_font_italic= font_flags & F_ITALIC;
   p_font_underline= font_flags & F_UNDERLINE;p_font_strike_thru=font_flags&F_STRIKE_THRU;
   p_font_charset=charset;
   p_redraw=1;

   width=_default_option('R');
   if (!width) {
     width=700;  // user can set this if not using Vertical
                 // line column

   } else {
      //We need to convert the columns to p_xyscale_mode
      width+=4;  // This is to accomodate for the width of the window.
      width+=8;  // Make a bit wider, adjust extra columns to taste.
      col=width*p_font_width;
      width=col;
   }
   activate_window(orig_wid);
   //say('width='width);
#endif
}

kjfb

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: How do I get SlickEdit to create smaller windows
« Reply #25 on: August 23, 2012, 09:24:25 AM »
hello community,

i use SE 9. how do i bring this "macro" or code above to life in this version? can i include this code to some .e ?

greetings

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Re: How do I get SlickEdit to create smaller windows
« Reply #26 on: October 06, 2012, 09:42:03 PM »
hello community,

i use SE 9. how do i bring this "macro" or code above to life in this version? can i include this code to some .e ?

greetings

Here is what I am doing on Slick 12, maybe it will work for you. In "files.e" notice my additional code marked by "m.c.r" below:
Code: [Select]
static _str edit_status(int status,int &new_file_status,_str &first_info, int a2_flags, _str window_info)
{
   if ( first_info=='' ) {
      first_info=p_buf_id' 'p_window_id;
   }
   if ( status ) {
      if ( status!=NEW_FILE_RC ) { return(status); }
      new_file_status=NEW_FILE_RC;
   }
   if (!(a2_flags & EDIT_NOUNICONIZE) && p_window_state=='I') p_window_state='N';
   boolean displayTranslationError=false;
   if (p_encoding_translation_error) {
      if ((p_readonly_mode && block_was_read()>1) ||
          (_modename_eq(p_mode_name,'Fundamental') && block_was_read())) {
         displayTranslationError=true;
      }
   }
   // IF in read only mode AND we just loaded this file
   typeless x, y, width, height, state, icon_x, icon_y;
   if ( p_readonly_mode && block_was_read()>1) {
      int read_only_status=block_was_read();
      _str command='read-only-mode';
      if (!(a2_flags & EDIT_NOWARNINGS)) {
         if ( read_only_status==3 ) {
            message(nls('Warning:  You have read only access to this file'));
         } else {
            message(nls('Warning:  Another process has read access'));
         }
      }
      select_edit_mode('',false,true);
      do_xml_auto_validate();
      call_list('_internal_buffer_add_',p_buf_id,p_buf_name,p_buf_flags);
      call_list('_buffer_add_',p_buf_id,p_buf_name,p_buf_flags);
      if (a2_flags & EDIT_RESTOREPOS) {
         _restore_filepos(p_buf_name);
         parse window_info with  x y width height state icon_x icon_y;
         if (window_info!='' && def_one_file!='') {
            if (state=='I') {
               p_window_state='N';
            } else {
               p_window_state=state;
            }
            _move_window(x,y,width,height,'N'/*,icon_x,icon_y*/);
         }
      }
      if ( index_callable(find_index(command,COMMAND_TYPE)) ) {
         if ( read_only_status==3 ) {
            execute(command,"");
         } else {
            execute(command' 1',"");
         }
      }
   } else if ( _modename_eq(p_mode_name,'Fundamental')) {
      // IF we just loaded this file OR a new file was created
      if (block_was_read() || status==NEW_FILE_RC) {
         select_edit_mode('',false,true);
         if (status != NEW_FILE_RC) {
            // 7/5/2006 - RB
            // Found this problem while opening an XML file over FTP with auto-validation turned on.
            // Calling do_xml_auto_validate will cause the Output tool window to
            // auto show if it was auto hidden, which would change the active window
            // away from the current MDI child, which would cause all the property
            // accesses (p_buf_name, p_buf_id, etc.) to throw a stack. For this
            // reason we save and restore the active window.
            int old_wid = p_window_id;
            do_xml_auto_validate();
            p_window_id=old_wid;
         }
         call_list('_internal_buffer_add_',p_buf_id,p_buf_name,p_buf_flags);
         call_list('_buffer_add_',p_buf_id,p_buf_name,p_buf_flags);
         if (!status && (a2_flags & EDIT_RESTOREPOS)) {
            //Msg('files.e:edit_status:1');
            _restore_filepos(p_buf_name);
            parse window_info with x y width height state icon_x icon_y;
            //Msg('files.e:edit_status:1:window_info:'window_info);
            if (window_info!='' && def_one_file!='') {
               if (state=='I') {
                  p_window_state='N';
               } else {
                  p_window_state=state;
               }
               _move_window(x,y,width,height,'N'/*,icon_x,icon_y*/);
               //m.c.r+
            }else{
               call_list('_on_mybuffer_add_nopos_',p_window_id,p_buf_id,p_buf_name,p_buf_flags);
            }
            //m.c.r-

         }
      }
   }
   if (displayTranslationError) {
      _message_box("Warning:  Not all characters could be translated to Unicode.  Untranslatable characters have been replaced by '?' characters.  Make sure you specified the correct encoding.\n\nSaving this file will NOT restore the file's original content.");
   }
   return(0);
}

And here is the system it calls:
Code: [Select]
int _on_mybuffer_add_nopos_edit_ignore=0;
int _on_mybuffer_add_nopos_edit_rows=3;
int _on_mybuffer_add_nopos_edit_cols=3;
int _on_mybuffer_add_nopos_edit_p=0;
void add_nopos_edit_xywh(int &x,int &y,int &w,int &h)
{
    _on_mybuffer_add_nopos_edit_rows=4;
    _on_mybuffer_add_nopos_edit_cols=3;
   s='';
   _mdi._MDIClientGetWindow(mx,my,mw,mh);
   s=' mx:'mx' my:'my' mw:'mw' mh:'mh s;
   int caph=30;// caption height -- leave room at bottom of MDI for minimized windows
   int hd=mw intdiv _on_mybuffer_add_nopos_edit_cols;
   s=' hd:'hd s;
   //int vd=(mh - (caph*2)) intdiv _on_mybuffer_add_nopos_edit_rows;
   int vd=mh intdiv _on_mybuffer_add_nopos_edit_rows;
   s=' vd:'vd s;
   int p=_on_mybuffer_add_nopos_edit_p% (_on_mybuffer_add_nopos_edit_cols*_on_mybuffer_add_nopos_edit_rows);
   s=' p:'p s;
   int col=p % _on_mybuffer_add_nopos_edit_cols;
   int row=(p) intdiv _on_mybuffer_add_nopos_edit_rows;
   x=col*hd;
   y=row*vd+caph;
   w=hd;
   h=vd;
   s='col:'col' row:'row' x:'x' y:'y' w:'w' h:'h s;
   s=' _on_mybuffer_add_nopos_edit_p:'_on_mybuffer_add_nopos_edit_p s;
   //say(s);
}

//FROM call_list('_on_mybuffer_add_nopos_',p_window_id,p_buf_id,p_buf_name,p_buf_flags);
void _on_mybuffer_add_nopos_edit(int wid,int bid,_str bn,_str bfl)
{
   if (_on_mybuffer_add_nopos_edit_ignore) {
      return;
   }
   _mdi._MDIClientGetWindow(mx,my,mw,mh);
   add_nopos_edit_xywh(x,y,w,h);
   if (1) {
      wid.p_y=y;
      wid.p_x=x;
      wid.p_width=w;
      wid.p_height=h;
   }
   _on_mybuffer_add_nopos_edit_p++;
   return;
}



Good luck!