/[weechat]/weechat/src/gui/curses/gui-display.c
ViewVC logotype

Diff of /weechat/src/gui/curses/gui-display.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.132 by flashcode, Sun Nov 13 15:51:00 2005 UTC revision 1.133 by flashcode, Sun Nov 13 22:14:06 2005 UTC
# Line 1154  gui_display_word (t_gui_window *window, Line 1154  gui_display_word (t_gui_window *window,
1154                    
1155          /* display new line? */          /* display new line? */
1156          if ((data >= end_line) ||          if ((data >= end_line) ||
1157              ((window->win_chat_cursor_y <= window->win_chat_height - 1) &&              (((simulate) ||
1158                 (window->win_chat_cursor_y <= window->win_chat_height - 1)) &&
1159              (window->win_chat_cursor_x > (window->win_chat_width - 1))))              (window->win_chat_cursor_x > (window->win_chat_width - 1))))
1160              gui_display_new_line (window, num_lines, count,              gui_display_new_line (window, num_lines, count,
1161                                    lines_displayed, simulate);                                    lines_displayed, simulate);
# Line 2796  gui_window_init_subwindows (t_gui_window Line 2797  gui_window_init_subwindows (t_gui_window
2797  }  }
2798    
2799  /*  /*
2800     * gui_window_auto_resize: auto-resize all windows, according to % of global size
2801     *                         This function is called after a terminal resize.
2802     *                         Returns 0 if ok, -1 if all window should be merged
2803     *                         (not enough space according to windows %)
2804     */
2805    
2806    int
2807    gui_window_auto_resize (t_gui_window_tree *tree,
2808                            int x, int y, int width, int height,
2809                            int simulate)
2810    {
2811        int size1, size2;
2812        
2813        if (tree)
2814        {
2815            if (tree->window)
2816            {
2817                if ((width < WINDOW_MIN_WIDTH) || (height < WINDOW_MIN_HEIGHT))
2818                    return -1;
2819                if (!simulate)
2820                {
2821                    tree->window->win_x = x;
2822                    tree->window->win_y = y;
2823                    tree->window->win_width = width;
2824                    tree->window->win_height = height;
2825                }
2826            }
2827            else
2828            {
2829                if (tree->split_horiz)
2830                {
2831                    size1 = (height * tree->split_pct) / 100;
2832                    size2 = height - size1;
2833                    if (gui_window_auto_resize (tree->child1, x, y + size1,
2834                                                width, size2, simulate) < 0)
2835                        return -1;
2836                    if (gui_window_auto_resize (tree->child2, x, y,
2837                                                width, size1, simulate) < 0)
2838                        return -1;
2839                }
2840                else
2841                {
2842                    size1 = (width * tree->split_pct) / 100;
2843                    size2 = width - size1 - 1;
2844                    if (gui_window_auto_resize (tree->child1, x, y,
2845                                                size1, height, simulate) < 0)
2846                        return -1;
2847                    if (gui_window_auto_resize (tree->child2, x + size1 + 1, y,
2848                                                size2, height, simulate) < 0)
2849                        return -1;
2850                }
2851            }
2852        }
2853        return 0;
2854    }
2855    
2856    /*
2857     * gui_refresh_windows: auto resize and refresh all windows
2858     */
2859    
2860    void
2861    gui_refresh_windows ()
2862    {
2863        t_gui_window *ptr_win, *old_current_window;
2864        
2865        if (gui_ok)
2866        {
2867            old_current_window = gui_current_window;
2868            
2869            if (gui_window_auto_resize (gui_windows_tree, 0, 0, COLS, LINES, 0) < 0)
2870                gui_window_merge_all (gui_current_window);
2871        
2872            for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
2873            {
2874                gui_switch_to_buffer (ptr_win, ptr_win->buffer);
2875                gui_redraw_buffer (ptr_win->buffer);
2876                gui_draw_window_separator (ptr_win);
2877            }
2878            
2879            gui_current_window = old_current_window;
2880            gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
2881            gui_redraw_buffer (gui_current_window->buffer);
2882        }
2883    }
2884    
2885    /*
2886   * gui_window_split_horiz: split a window horizontally   * gui_window_split_horiz: split a window horizontally
2887   */   */
2888    
# Line 2882  gui_window_split_vertic (t_gui_window *w Line 2969  gui_window_split_vertic (t_gui_window *w
2969  }  }
2970    
2971  /*  /*
2972     * gui_window_resize: resize window
2973     */
2974    
2975    void
2976    gui_window_resize (t_gui_window *window, int pourcentage)
2977    {
2978        t_gui_window_tree *parent;
2979        int old_split_pct;
2980        
2981        parent = window->ptr_tree->parent_node;
2982        if (parent)
2983        {
2984            old_split_pct = parent->split_pct;
2985            if (((parent->split_horiz) && (window->ptr_tree == parent->child2))
2986                || ((!(parent->split_horiz)) && (window->ptr_tree == parent->child1)))
2987                parent->split_pct = pourcentage;
2988            else
2989                parent->split_pct = 100 - pourcentage;
2990            if (gui_window_auto_resize (gui_windows_tree, 0, 0, COLS, LINES, 1) < 0)
2991                parent->split_pct = old_split_pct;
2992            else
2993                gui_refresh_windows ();
2994        }
2995    }
2996    
2997    /*
2998   * gui_window_merge: merge window with its sister   * gui_window_merge: merge window with its sister
2999   */   */
3000    
# Line 2951  gui_window_merge_all (t_gui_window *wind Line 3064  gui_window_merge_all (t_gui_window *wind
3064  }  }
3065    
3066  /*  /*
  * gui_window_auto_resize: auto-resize all windows, according to % of global size  
  *                         This function is called after a terminal resize.  
  *                         Returns 0 if ok, -1 if all window should be merged  
  *                         (not enough space according to windows %)  
  */  
   
 void  
 gui_window_auto_resize (t_gui_window_tree *tree,  
                         int x, int y, int width, int height)  
 {  
     int size1, size2;  
       
     if (tree)  
     {  
         if (tree->window)  
         {  
             tree->window->win_x = x;  
             tree->window->win_y = y;  
             tree->window->win_width = width;  
             tree->window->win_height = height;  
         }  
         else  
         {  
             if (tree->split_horiz)  
             {  
                 size1 = (height * tree->split_pct) / 100;  
                 size2 = height - size1;  
                 gui_window_auto_resize (tree->child1, x, y + size1, width, size2);  
                 gui_window_auto_resize (tree->child2, x, y, width, size1);  
             }  
             else  
             {  
                 size1 = (width * tree->split_pct) / 100;  
                 size2 = width - size1 - 1;  
                 gui_window_auto_resize (tree->child1, x, y, size1, height);  
                 gui_window_auto_resize (tree->child2, x + size1 + 1, y, size2, height);  
             }  
         }  
     }  
 }  
   
 /*  
3067   * gui_refresh_screen: called when term size is modified   * gui_refresh_screen: called when term size is modified
3068   */   */
3069    
3070  void  void
3071  gui_refresh_screen ()  gui_refresh_screen ()
3072  {  {
3073      t_gui_window *ptr_win, *old_current_window;      int new_height, new_width;
     int old_width, old_height;  
     int new_width, new_height;  
     int merge_all;  
       
     getmaxyx (stdscr, old_height, old_width);  
3074            
3075      endwin ();      endwin ();
3076      refresh ();      refresh ();
3077            
3078      getmaxyx (stdscr, new_height, new_width);      getmaxyx (stdscr, new_height, new_width);
3079            
     old_current_window = gui_current_window;  
       
3080      gui_ok = ((new_width > WINDOW_MIN_WIDTH) && (new_height > WINDOW_MIN_HEIGHT));      gui_ok = ((new_width > WINDOW_MIN_WIDTH) && (new_height > WINDOW_MIN_HEIGHT));
3081            
3082      if (gui_ok)      if (gui_ok)
3083      {          gui_refresh_windows ();
         gui_window_auto_resize (gui_windows_tree, 0, 0, COLS, LINES);  
           
         merge_all = 0;  
         for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)  
         {  
             if ((ptr_win->win_width < WINDOW_MIN_WIDTH)  
                 || (ptr_win->win_height < WINDOW_MIN_HEIGHT))  
             {  
                 merge_all = 1;  
                 break;  
             }  
         }  
         if (merge_all)  
             gui_window_merge_all (gui_current_window);  
       
         for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)  
         {  
             gui_switch_to_buffer (ptr_win, ptr_win->buffer);  
             gui_redraw_buffer (ptr_win->buffer);  
             gui_draw_window_separator (ptr_win);  
         }  
           
         gui_current_window = old_current_window;  
         gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);  
         gui_redraw_buffer (gui_current_window->buffer);  
     }  
3084  }  }
3085    
3086  /*  /*

Legend:
Removed from v.1.132  
changed lines
  Added in v.1.133

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26