home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / jade-3.0.lha / Jade / src / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-19  |  16.5 KB  |  655 lines

  1. /* windows.c -- System-independant window handling
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4. This file is part of Jade.
  5.  
  6. Jade is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. Jade is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with Jade; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "jade.h"
  21. #include "jade_protos.h"
  22.  
  23. #include <stdarg.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26.  
  27. _PR void settitle(u_char *);
  28. _PR void settitlefmt(u_char *, ...);
  29. _PR void notitle(VW *);
  30. _PR void stdtitle(VW *);
  31. _PR void resettitle(VW *);
  32. _PR void windows_init(void);
  33. _PR void windows_kill(void);
  34. _PR void window_sweep(void);
  35. _PR void window_prin(VALUE, VALUE);
  36.  
  37. VALUE sym_make_window_hook, sym_destroy_window_hook;
  38.  
  39. /* This can contain `dead' windows, ie vw_Window==NULL, they have been
  40.    close'd but must hang around until we're sure all refs are dead.  */
  41. _PR   VW     *ViewChain;
  42. /* CurrVW is the active window */
  43. _PR   VW     *CurrVW;
  44. _PR   int      NumWindows;
  45. _PR   bool  LogMsgs;
  46.  
  47. VW   *ViewChain;
  48. VW   *CurrVW;
  49. int   NumWindows;
  50. bool  LogMsgs;
  51.  
  52. _PR VALUE cmd_make_window(VALUE xv, VALUE yv, VALUE wv, VALUE hv);
  53. DEFUN("make-window", cmd_make_window, subr_make_window, (VALUE xv, VALUE yv, VALUE wv, VALUE hv), V_Subr4, DOC_make_window) /*
  54. ::doc:make_window::
  55. (make-window [X] [Y] [WIDTH] [HEIGHT])
  56. Return a new window, it will be displaying the same buffer as the currently
  57. active window.
  58. ::end:: */
  59. {
  60.     VW *vw;
  61.     TX *tx = CurrVW ? CurrVW->vw_Tx : NULL;
  62.     if(NUMBERP(xv))
  63.     DefDims[0] = VNUM(xv);
  64.     if(NUMBERP(yv))
  65.     DefDims[1] = VNUM(yv);
  66.     if(NUMBERP(wv))
  67.     DefDims[2] = VNUM(wv);
  68.     if(NUMBERP(hv))
  69.     DefDims[3] = VNUM(hv);
  70.     vw = mycalloc(sizeof(VW));
  71.     if(vw)
  72.     {
  73.     vw->vw_Type = V_Window;
  74.     vw->vw_Next = ViewChain;
  75.     ViewChain = vw;
  76.     copywinprefs(vw, CurrVW);
  77.     if(setfont(vw))
  78.     {
  79.         vw->vw_Window = newwindow(CurrVW, vw, TRUE);
  80.         if(vw->vw_Window)
  81.         {
  82.         NumWindows++;
  83.         os_newvw(vw);
  84.         vw->vw_BlockStatus = -1;
  85.         vw->vw_LocalVariables = sym_nil;
  86.         updatedimensions(vw);
  87.         if(tx)
  88.         {
  89.             vw->vw_Tx = tx;
  90.             vw->vw_CursorPos = tx->tx_SavedCPos;
  91.             vw->vw_StartLine = tx->tx_SavedWPos.pos_Line;
  92.             vw->vw_StartCol = tx->tx_SavedWPos.pos_Col;
  93.             stdtitle(vw);
  94.             cmd_eval_hook2(sym_make_window_hook, vw);
  95.         }
  96. #ifndef NOSCRLBAR
  97.         updatescroller(vw);
  98. #endif
  99.         vw->vw_Flags |= VWFF_FORCE_REFRESH;
  100.         return(vw);
  101.         }
  102.         unsetfont(vw);
  103.     }
  104.     myfree(vw);
  105.     }
  106.     return(NULL);
  107. }
  108.  
  109. _PR VALUE cmd_destroy_window(VALUE win);
  110. DEFUN("destroy-window", cmd_destroy_window, subr_destroy_window, (VALUE win), V_Subr1, DOC_destroy_window) /*
  111. ::doc:destroy_window::
  112. (destroy-window [WINDOW])
  113. Close WINDOW (or the current window), if this was the last one all files in
  114. memory are flushed and jade will exit.
  115. ::end:: */
  116. {
  117.     VW *vw = WINDOWP(win) ? VWIN(win) : CurrVW;
  118.     cmd_eval_hook2(sym_destroy_window_hook, vw);
  119.     notitle(vw);
  120.     /* This function is to take care of OS-independant stuff:
  121.        releasing GCs etc...  */
  122.     os_killvw(vw);
  123.     killwindow(vw);
  124.     unsetfont(vw);
  125.     NumWindows--;
  126.     /* This flags that this window is dead.  */
  127.     vw->vw_Window = WINDOW_NIL;
  128.     vw->vw_Tx = NULL;
  129.     if(CurrVW == vw)
  130.     {
  131.     while((vw = vw->vw_Next))
  132.     {
  133.         if(vw->vw_Window)
  134.         {
  135.         CurrVW = vw;
  136.         return(vw);
  137.         }
  138.     }
  139.     vw = ViewChain;
  140.     while(vw && (vw != CurrVW))
  141.     {
  142.         if(vw->vw_Window)
  143.         {
  144.         CurrVW = vw;
  145.         return(vw);
  146.         }
  147.         vw = vw->vw_Next;
  148.     }
  149.     /* No living windows left :-( we'll die soon :-(  */
  150.     CurrVW = NULL;
  151.     ThrowValue = cmd_cons(sym_quit, newnumber(0)); /* experimental. */
  152.     return(NULL);
  153.     }
  154.     return(CurrVW);
  155. }
  156.  
  157. _PR VALUE cmd_sleep_window(VALUE vw);
  158. DEFUN("sleep-window", cmd_sleep_window, subr_sleep_window, (VALUE vw), V_Subr1, DOC_sleep_window) /*
  159. ::doc:sleep_window::
  160. (sleep-window [WINDOW])
  161. Iconifies the current window.
  162. ::end:: */
  163. {
  164.     if(!WINDOWP(vw))
  165.     vw = CurrVW;
  166.     if((!VWIN(vw)->vw_Sleeping) && sleepwin(VWIN(vw)))
  167.     return(vw);
  168.     return(sym_nil);
  169. }
  170.  
  171. _PR VALUE cmd_unsleep_window(VALUE vw);
  172. DEFUN("unsleep-window", cmd_unsleep_window, subr_unsleep_window, (VALUE vw), V_Subr1, DOC_unsleep_window) /*
  173. ::doc:unsleep_window::
  174. (unsleep-window [WINDOW])
  175. Uniconifies the current window.
  176. ::end:: */
  177. {
  178.     if(!WINDOWP(vw))
  179.     vw = CurrVW;
  180.     if((VWIN(vw)->vw_Sleeping) && unsleep(VWIN(vw)))
  181.     return(vw);
  182.     return(sym_nil);
  183. }
  184.  
  185. _PR VALUE cmd_next_window(VALUE vw, VALUE activ);
  186. DEFUN("next-window", cmd_next_window, subr_next_window, (VALUE vw, VALUE activ), V_Subr2, DOC_next_window) /*
  187. ::doc:next_window::
  188. (next-window [WINDOW] [ACTIVATE])
  189. Cycles through the open windows forwards.
  190. ::end:: */
  191. {
  192.     if(!WINDOWP(vw))
  193.     vw = CurrVW->vw_Next;
  194.     while(vw != CurrVW)
  195.     {
  196.     if(!vw)
  197.         vw = ViewChain;
  198.     if(VWIN(vw)->vw_Window)
  199.     {
  200.         if(!NILP(activ))
  201.         {
  202.         CurrVW = VWIN(vw);
  203.         activatewin(VWIN(vw));
  204.         }
  205.         return(vw);
  206.     }
  207.     vw = VWIN(vw)->vw_Next;
  208.     }
  209.     return(CurrVW);
  210. }
  211.  
  212. void
  213. settitle(u_char *title)
  214. {
  215.     VW *vw = CurrVW;
  216.     if(LogMsgs)
  217.     fprintf(stderr, "%s\n", title);
  218.     if(!vw->vw_Sleeping)
  219.     {
  220.     mystrfree(vw->vw_LastTitle);
  221.     vw->vw_LastTitle = mystrdup(title);
  222.     vw->vw_NonStdTitle = TRUE;
  223.     vw->vw_Flags |= VWFF_REFRESH_STATUS;
  224.     }
  225. }
  226.  
  227. /*
  228.  * Is my usage of va_* correct??
  229.  */
  230. void
  231. settitlefmt(u_char *fmt, ...)
  232. {
  233.     VW *vw = CurrVW;
  234.     va_list args;
  235.     if(!vw->vw_Sleeping)
  236.     {
  237.     u_char fmtbuff[256];
  238.     va_start(args, fmt);
  239.     vsprintf(fmtbuff, fmt, args);
  240.     va_end(args);
  241.     if(LogMsgs)
  242.        fprintf(stderr, "%s\n", fmtbuff);
  243.     mystrfree(vw->vw_LastTitle);
  244.     vw->vw_LastTitle = mystrdup(fmtbuff);
  245.     vw->vw_NonStdTitle = TRUE;
  246.     vw->vw_Flags |= VWFF_REFRESH_STATUS;
  247.     }
  248. }
  249.  
  250. void
  251. notitle(VW *vw)
  252. {
  253.     if(!vw->vw_Sleeping && vw->vw_LastTitle)
  254.     {
  255.     mystrfree(vw->vw_LastTitle);
  256.     vw->vw_LastTitle = NULL;
  257.     vw->vw_NonStdTitle = FALSE;
  258.     vw->vw_Flags |= VWFF_REFRESH_STATUS;
  259.     }
  260. }
  261.  
  262. void
  263. stdtitle(VW *vw)
  264. {
  265.     if((!vw->vw_NonStdTitle) && (!vw->vw_Sleeping))
  266.     {
  267.     TX *tx = vw->vw_Tx;
  268.     u_char *blk;
  269.     u_char fmtbuff[100];
  270.     if(vw->vw_BlockStatus >= 0)
  271.     {
  272.         if(!vw->vw_BlockStatus)
  273.         blk = "B";
  274.         else
  275.         blk = "b";
  276.     }
  277.     else
  278.         blk = "";
  279.     mystrfree(vw->vw_LastTitle);
  280.     sprintf(fmtbuff, "%s%s [%s] (%ld,%ld) %ld line(s) [%s%ld]",
  281.         VSTR(tx->tx_BufferName),
  282.         ((tx->tx_Changes != tx->tx_ProperSaveChanges) && (!(tx->tx_Flags & TXFF_SPECIAL))) ? "+" : (tx->tx_Flags & TXFF_RDONLY ? "-" : ""),
  283.         (tx->tx_ModeName ? (char *)VSTR(tx->tx_ModeName) : "generic"),
  284.         vw->vw_CursorPos.pos_Col + 1,
  285.         vw->vw_CursorPos.pos_Line + 1,
  286.         tx->tx_NumLines,
  287.         blk,
  288.         tx->tx_SaveTabs);
  289.     vw->vw_LastTitle = mystrdup(fmtbuff);
  290.     vw->vw_Flags |= VWFF_REFRESH_STATUS;
  291.     }
  292. }
  293.  
  294. void
  295. resettitle(VW *vw)
  296. {
  297.     vw->vw_NonStdTitle = FALSE;
  298. }
  299.  
  300. _PR VALUE cmd_title(VALUE string);
  301. DEFUN("title", cmd_title, subr_title, (VALUE string), V_Subr1, DOC_title) /*
  302. ::doc:title::
  303. (title STRING)
  304. Temporarily sets the status display to STRING, this won't happen until the
  305. window is next refreshed.
  306. ::end:: */
  307. {
  308.     DECLARE1(string, STRINGP);
  309.     settitle(VSTR(string));
  310.     return(string);
  311. }
  312.  
  313. _PR VALUE cmd_title_now(VALUE string);
  314. DEFUN("title-now", cmd_title_now, subr_title_now, (VALUE string), V_Subr1, DOC_title_now) /*
  315. ::doc:title_now::
  316. (title STRING)
  317. Immediately sets the status display to STRING.
  318. ::end:: */
  319. {
  320.     DECLARE1(string, STRINGP);
  321.     settitle(VSTR(string));
  322.     setvwtitle(CurrVW);
  323.     CurrVW->vw_Flags &= ~VWFF_REFRESH_STATUS;
  324. #ifdef HAVE_X11
  325.     XFlush(XDisplay);
  326. #endif
  327.     return(string);
  328. }
  329.  
  330. _PR VALUE cmd_font_name(VALUE vw);
  331. DEFUN("font-name", cmd_font_name, subr_font_name, (VALUE vw), V_Subr1, DOC_font_name) /*
  332. ::doc:font_name::
  333. (font-name [WINDOW])
  334. Returns the name of the font being used in this window.
  335. ::end:: */
  336. {
  337.     if(!WINDOWP(vw))
  338.     vw = CurrVW;
  339.     return(VWIN(vw)->vw_FontName);
  340. }
  341.  
  342. _PR VALUE var_max_scroll(VALUE val);
  343. DEFUN("max-scroll", var_max_scroll, subr_max_scroll, (VALUE val), V_Var, DOC_max_scroll) /*
  344. ::doc:max_scroll::
  345. Maximum scroll distance (number of lines). If a set of lines has to be
  346. scrolled further than this the whole window is redrawn.
  347. ::end:: */
  348. {
  349.     VW *vw = CurrVW;
  350.     if(val)
  351.     {
  352.     if(NUMBERP(val))
  353.         vw->vw_MaxScroll = VNUM(val);
  354.     return(NULL);
  355.     }
  356.     return(newnumber(vw->vw_MaxScroll));
  357. }
  358.  
  359. _PR VALUE var_y_scroll_step_ratio(VALUE val);
  360. DEFUN("y-scroll-step-ratio", var_y_scroll_step_ratio, subr_y_scroll_step_ratio, (VALUE val), V_Var, DOC_y_scroll_step_ratio) /*
  361. ::doc:y_scroll_step_ratio::
  362. Controls the actual number of lines scrolled when the cursor moves out of
  363. view. The number of lines to move the display origin is calcualted with the
  364. formula:
  365.   LINES_TO_SCROLL = TOTAL_LINES_IN_WINDOW / y-scroll-step-ratio
  366. If the value is 0 then the window will be scrolled by one line.
  367. ::end:: */
  368. {
  369.     VW *vw = CurrVW;
  370.     if(val)
  371.     {
  372.     if(NUMBERP(val))
  373.     {
  374.         vw->vw_YStepRatio = VNUM(val);
  375.         updatedimensions(vw);
  376.     }
  377.     return(NULL);
  378.     }
  379.     return(newnumber(vw->vw_YStepRatio));
  380. }
  381.  
  382. _PR VALUE var_x_scroll_step_ratio(VALUE val);
  383. DEFUN("x-scroll-step-ratio", var_x_scroll_step_ratio, subr_x_scroll_step_ratio, (VALUE val), V_Var, DOC_x_scroll_step_ratio) /*
  384. ::doc:x_scroll_step_ratio::
  385. Controls the actual number of columns scrolled when the cursor moves out of
  386. view. The number of lines to move the display origin is calcualted with the
  387. formula:
  388.   COLUMNS_TO_SCROLL = TOTAL_COLUMNS_IN_WINDOW / x-scroll-step-ratio
  389. If the value is 0 then the window will be scrolled by one column.
  390. ::end:: */
  391. {
  392.     VW *vw = CurrVW;
  393.     if(val)
  394.     {
  395.     if(NUMBERP(val))
  396.     {
  397.         vw->vw_XStepRatio = VNUM(val);
  398.         updatedimensions(vw);
  399.     }
  400.     return(NULL);
  401.     }
  402.     return(newnumber(vw->vw_XStepRatio));
  403. }
  404.  
  405. _PR VALUE cmd_rect_blocks_p(VALUE vw);
  406. DEFUN("rect-blocks-p", cmd_rect_blocks_p, subr_rect_blocks_p, (VALUE vw), V_Subr1, DOC_rect_blocks_p) /*
  407. ::doc:rect_blocks_p::
  408. (rect-blocks-p [WINDOW])
  409. Returns t if blocks marked in WINDOW (or the current one) are treated as
  410. rectangles.
  411. ::end:: */
  412. {
  413.     if(!WINDOWP(vw))
  414.     vw = CurrVW;
  415.     if(VWIN(vw)->vw_Flags & VWFF_RECTBLOCKS)
  416.     return(sym_t);
  417.     return(sym_nil);
  418. }
  419.  
  420. _PR VALUE cmd_set_rect_blocks(VALUE vw, VALUE stat);
  421. DEFUN("set-rect-blocks", cmd_set_rect_blocks, subr_set_rect_blocks, (VALUE vw, VALUE stat), V_Subr2, DOC_set_rect_blocks) /*
  422. ::doc:set_rect_blocks::
  423. (set-rect-blocks WINDOW STATUS)
  424. Controls whether or not blocks are taken as contiguous regions of text or as
  425. rectangles in WINDOW. When STATUS is t rectangles are used.
  426. ::end:: */
  427. {
  428.     int oflags;
  429.     if(!WINDOWP(vw))
  430.     vw = CurrVW;
  431.     oflags = VWIN(vw)->vw_Flags;
  432.     if(NILP(stat))
  433.     VWIN(vw)->vw_Flags &= ~VWFF_RECTBLOCKS;
  434.     else
  435.     VWIN(vw)->vw_Flags |= VWFF_RECTBLOCKS;
  436.     if((VWIN(vw)->vw_BlockStatus == 0) && (VWIN(vw)->vw_Flags != oflags))
  437.     setblockrefresh(VWIN(vw));
  438.     return(stat);
  439. }
  440.  
  441. _PR VALUE cmd_window_asleep_p(void);
  442. DEFUN("window-asleep-p", cmd_window_asleep_p, subr_window_asleep_p, (void), V_Subr0, DOC_window_asleep_p) /*
  443. ::doc:window_asleep_p::
  444. (window-asleep-p)
  445. Returns t if window is currently iconified.
  446. ::end:: */
  447. {
  448.     if(CurrVW->vw_Sleeping)
  449.     return(sym_t);
  450.     return(sym_nil);
  451. }
  452.  
  453. _PR VALUE cmd_window_count(void);
  454. DEFUN("window-count", cmd_window_count, subr_window_count, (void), V_Subr0, DOC_window_count) /*
  455. ::doc:window_count::
  456. (window-count)
  457. Number of opened windows.
  458. ::end:: */
  459. {
  460.     return(newnumber(NumWindows));
  461. }
  462.  
  463. _PR VALUE cmd_position_window(VALUE left, VALUE top, VALUE width, VALUE height);
  464. DEFUN("position-window", cmd_position_window, subr_position_window, (VALUE left, VALUE top, VALUE width, VALUE height), V_Subr4, DOC_position_window) /*
  465. ::doc:position_window::
  466. (position-window LEFT TOP WIDTH HEIGHT)
  467. Sets the position and dimensions of the current window. These are all
  468. *pixel* measurememnts.
  469. ::end:: */
  470. {
  471.     VW *vw = CurrVW;
  472.     DECLARE1(left, NUMBERP);
  473.     DECLARE2(top, NUMBERP);
  474.     DECLARE3(width, NUMBERP);
  475.     DECLARE4(height, NUMBERP);
  476.     setvwpos(vw, VNUM(left), VNUM(top), VNUM(width), VNUM(height));
  477.     return(sym_t);
  478. }
  479.  
  480. _PR VALUE cmd_current_window(void);
  481. DEFUN("current-window", cmd_current_window, subr_current_window, (void), V_Subr0,  DOC_current_window) /*
  482. ::doc:current_window::
  483. (current-window)
  484. Returns the currently active window. Note that this is the editor's notion
  485. of `current' -- it doesn't necessarily mean that this is the window to which
  486. your window system will send input events to.
  487. ::end:: */
  488. {
  489.     return(CurrVW);
  490. }
  491.  
  492. _PR VALUE cmd_with_window(VALUE args);
  493. DEFUN("with-window", cmd_with_window, subr_with_window, (VALUE args), V_SF, DOC_with_window) /*
  494. ::doc:with_window::
  495. (with-window WINDOW FORMS...) <SPECIAL-FORM>
  496. Set the editor's current window to WINDOW and evaluate FORMS, then
  497. reinstall the original window as the current one.
  498. ::end:: */
  499. {
  500.     if(CONSP(args))
  501.     {
  502.     GCVAL gcv_args;
  503.     VALUE res;
  504.     PUSHGC(gcv_args, args);
  505.     if((res = cmd_eval(VCAR(args))) && WINDOWP(res))
  506.     {
  507.         VALUE oldvw = CurrVW;
  508.         GCVAL gcv_oldvw;
  509.         CurrVW = VWIN(res);
  510.         PUSHGC(gcv_oldvw, oldvw);
  511.         res = cmd_progn(VCDR(args));
  512.         POPGC;
  513.         CurrVW = VWIN(oldvw);
  514.     }
  515.     POPGC;
  516.     return(res);
  517.     }
  518.     return(NULL);
  519. }
  520.  
  521. _PR VALUE cmd_set_current_window(VALUE vw, VALUE activ);
  522. DEFUN("set-current-window", cmd_set_current_window, subr_set_current_window, (VALUE vw, VALUE activ), V_Subr2,  DOC_set_current_window) /*
  523. ::doc:set_current_window::
  524. (set-current-window WINDOW [ACTIVATE-P])
  525. Sets the window which jade reguards as current.
  526. If ACTIVATE-P is non-nil the window will be activated with respect to the
  527. window-system (under X11 this means warping the pointer to the top left corner
  528. of the window as well).
  529. ::end:: */
  530. {
  531.     DECLARE1(vw, WINDOWP);
  532.     CurrVW = VWIN(vw);
  533.     if(!NILP(activ))
  534.     activatewin(VWIN(vw));
  535.     return(CurrVW);
  536. }
  537.  
  538. _PR VALUE cmd_window_id(VALUE vw);
  539. DEFUN("window-id", cmd_window_id, subr_window_id, (VALUE vw), V_Subr1, DOC_window_id) /*
  540. ::doc:window_id::
  541. (window-id [WINDOW])
  542. Returns the identifier of the physical window that the Lisp window WINDOW
  543. points to. This is window-system dependant, under X11 it will be some integer,
  544. under Intuition a pointer (integer) to the window structure.
  545. ::end:: */
  546. {
  547.     if(!WINDOWP(vw))
  548.     vw = CurrVW;
  549.     return(newnumber((long)VWIN(vw)->vw_Window));
  550. }
  551.  
  552. _PR VALUE cmd_font_x_size(VALUE vw);
  553. DEFUN("font-x-size", cmd_font_x_size, subr_font_x_size, (VALUE vw), V_Subr1, DOC_font_x_size) /*
  554. ::doc:font_x_size::
  555. (font-x-size [WINDOW])
  556. Returns the width of the window's font (in pixels).
  557. ::end:: */
  558. {
  559.     if(!WINDOWP(vw))
  560.     vw = CurrVW;
  561.     return(newnumber((long)VWIN(vw)->vw_FontX));
  562. }
  563.  
  564. _PR VALUE cmd_font_y_size(VALUE vw);
  565. DEFUN("font-y-size", cmd_font_y_size, subr_font_y_size, (VALUE vw), V_Subr1, DOC_font_x_size) /*
  566. ::doc:font_y_size::
  567. (font-y-size [WINDOW])
  568. Returns the height of the window's font (in pixels).
  569. ::end:: */
  570. {
  571.     if(!WINDOWP(vw))
  572.     vw = CurrVW;
  573.     return(newnumber((long)VWIN(vw)->vw_FontY));
  574. }
  575.  
  576. void
  577. windows_init(void)
  578. {
  579.     ADD_SUBR(subr_make_window);
  580.     ADD_SUBR(subr_destroy_window);
  581.     ADD_SUBR(subr_sleep_window);
  582.     ADD_SUBR(subr_unsleep_window);
  583.     ADD_SUBR(subr_next_window);
  584.     ADD_SUBR(subr_title);
  585.     ADD_SUBR(subr_title_now);
  586.     ADD_SUBR(subr_font_name);
  587.     ADD_SUBR(subr_max_scroll);
  588.     ADD_SUBR(subr_y_scroll_step_ratio);
  589.     ADD_SUBR(subr_x_scroll_step_ratio);
  590.     ADD_SUBR(subr_rect_blocks_p);
  591.     ADD_SUBR(subr_set_rect_blocks);
  592.     ADD_SUBR(subr_window_asleep_p);
  593.     ADD_SUBR(subr_window_count);
  594.     ADD_SUBR(subr_position_window);
  595.     ADD_SUBR(subr_current_window);
  596.     ADD_SUBR(subr_set_current_window);
  597.     ADD_SUBR(subr_with_window);
  598.     ADD_SUBR(subr_window_id);
  599.     ADD_SUBR(subr_font_x_size);
  600.     ADD_SUBR(subr_font_y_size);
  601.     INTERN(sym_make_window_hook, "make-window-hook");
  602.     INTERN(sym_destroy_window_hook, "destroy-window-hook");
  603. }
  604. void
  605. windows_kill(void)
  606. {
  607.     VW *vw, *nxt;
  608.     while(CurrVW)
  609.     cmd_destroy_window(CurrVW);
  610.     vw = ViewChain;
  611.     while(vw)
  612.     {
  613.     nxt = vw->vw_Next;
  614.     myfree(vw);
  615.     vw = nxt;
  616.     }
  617. }
  618. void
  619. window_sweep(void)
  620. {
  621.     VW *vw = ViewChain;
  622.     ViewChain = NULL;
  623.     while(vw)
  624.     {
  625.     VW *nxt = vw->vw_Next;
  626.     if(GC_MARKEDP(vw))
  627.     {
  628.         GC_CLR(vw);
  629.         vw->vw_Next = ViewChain;
  630.         ViewChain = vw;
  631.     }
  632.     else
  633.         myfree(vw);
  634.     vw = nxt;
  635.     }
  636. }
  637. void
  638. window_prin(VALUE strm, VALUE vw)
  639. {
  640.     u_char buf[40];
  641.     if(VWIN(vw)->vw_Window)
  642.     {
  643. #ifdef HAVE_X11
  644.     sprintf(buf, "#<window %ld ", VWIN(vw)->vw_Window);
  645. #else
  646.     sprintf(buf, "#<window 0x%x ", VWIN(vw)->vw_Window);
  647. #endif
  648.     streamputs(strm, buf, FALSE);
  649.     streamputs(strm, VSTR(VWIN(vw)->vw_Tx->tx_BufferName), TRUE);
  650.     streamputc(strm, '>');
  651.     }
  652.     else
  653.     streamputs(strm, "#<dead-window>", FALSE);
  654. }
  655.