jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Re: A small and a large window on startup


On Wed, 29 Jan 2003 13:28:02 -0500 wrote Thomas Clausen <tclausen@xxxxxxxxxxxx>:

> Hi Martin,
> 
> I use the following. In .jedrc I define:
> 
> define window_set_rows (rows)
...

> Adapted from bufutils.sl. 

Nice idea to have this separated. Realizing the need for a non-fitting
tool to resize the window, I just made the necessary changes to bufutils.sl
You might consider applying the patch to version 1.2.1 and have a .jedrc
that is some lines shorter :-) (And tell me if there are problems)


--- bufutils1.2.1.sl        Thu Jan 30 12:00:52 2003
+++ bufutils.sl        Thu Jan 30 11:59:30 2003
@@ -4,6 +4,7 @@
 % Version 1.1  bugfix: restore_buffer now resets the "changed on disk" flag
 % Version 1.2  new: "blocal_hooks"
 % Version 1.2.1 new: push_array
+% Version 1.2.2 "outsourcing" of window_set_rows (hint by Thomas Clausen)
 
 %!%+
 %\function{push_defaults}
@@ -92,6 +93,48 @@
 % --- window operations ----------------------------------------------
 
 %!%+
+%\function{window_set_rows}
+%\synopsis{Make the window \var{rows} rows big}
+%\usage{Void window_set_rows(Int rows)}
+%\description
+%   Resizes the current window to have \var{rows} rows.
+%   If there is only one window, it will be split first.
+%   If rows is zero, the window is deleted
+%   If rows is negative, the window is reduced by \var{rows} lines.
+%   (You can use loop(rows) enlargewin(); to get relative enlargement.)
+%\notes
+%      
+%   If there are more than two windows opne, 
+%   the function might not work as desired.
+%\seealso{fit_window, enlargewin, onewindow}
+%!%-
+public define window_set_rows(rows)
+{
+   if (rows == 0)
+             call("delete_window");
+   if (rows < 0)
+       rows += window_info('r');
+   if (nwindows () - MINIBUFFER_ACTIVE == 1)
+     call("split_window");
+   if (rows >= SCREEN_HEIGHT-3)
+     onewindow();
+   variable misfit = rows - window_info('r');
+   if (misfit > 0) { % window too small
+      loop(misfit)
+        enlargewin ();
+   }
+   if (misfit < 0) { % window too large
+      variable curbuf = whatbuf();
+      otherwindow();
+      loop(-misfit)
+        enlargewin ();
+      loop(nwindows() - 1)
+        otherwindow();
+   }
+   recenter(what_line);
+}
+
+%!%+
 %\function{fit_window}
 %\synopsis{fits the window size to the lenght of the buffer}
 %\usage{ Void fit_window () % fit_window(max_rows = NULL)}
@@ -121,21 +164,7 @@
      if (wanted_rows > max_rows)
        wanted_rows = max_rows;
    % fit window
-   if(wanted_rows >= SCREEN_HEIGHT-3)
-     onewindow();
-   variable misfit = wanted_rows - window_info('r');
-   if (misfit > 0) { % window too small
-      loop(misfit)
-        enlargewin ();
-   }
-   if (misfit < 0) { % window too large
-      variable curbuf = whatbuf();
-      otherwindow;
-      loop(-misfit)
-        enlargewin ();
-      pop2buf(curbuf);
-   }
-   recenter(what_line);
+   window_set_rows(wanted_rows);
 }
 
 %!%+

Again, thanks for the hint.
Should I update it on JMR too? (lazy as I am, I consider waiting for some
more changes to collect before publishing the next version.)

Günter

--
Milde at ife.et.tu-dresden.de


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]