I think this is worse.


-------- Original message --------
From: Marcel Partap <mpartap@gmx.net>
Date: 27/10/2013 22:37 (GMT+00:00)
To: tmux-users@lists.sourceforge.net
Subject: [PATCH 3/4] Merge function into code block. Less confusion.


---
screen-redraw.c | 77 ++++++++++++++++++++-------------------------------------
1 file changed, 27 insertions(+), 50 deletions(-)

diff --git a/screen-redraw.c b/screen-redraw.c
index 6131907..1af1bb1 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -26,8 +26,6 @@ int screen_redraw_get_border_rel(struct window_pane *, u_int, u_int);
int screen_redraw_cell_is_border(struct client *, u_int, u_int);
int screen_redraw_get_cell_type(struct client *, u_int, u_int,
    struct window_pane **);
-int screen_redraw_check_active_pane_indicator(u_int, u_int, int, struct window *,
-     struct window_pane *);

void screen_redraw_draw_number(struct client *, struct window_pane *);

@@ -179,48 +177,6 @@ screen_redraw_get_cell_type(struct client *c, u_int px, u_int py,
return (CELL_OUTSIDE);
}

-/* Check active pane indicator. */
-int
-screen_redraw_check_active_pane_indicator(u_int px, u_int py, int type, struct window *w,
-    struct window_pane *wp)
-{
- /* Is this off the active pane border? */
- if (screen_redraw_get_border_rel(w->active, px, py) == BORDER_NOT)
- return (0);
-
- /* If there are more than two panes, that's enough. */
- if (window_count_panes(w) != 2)
- return (1);
-
- /* Else if the cell is not a border cell, forget it. */
- if (wp == NULL || (type == CELL_OUTSIDE || type == CELL_INSIDE))
- return (1);
-
- /* Check if the pane covers the whole width. */
- if (wp->xoff == 0 && wp->sx == w->sx) {
- /* This can either be the top pane or the bottom pane. */
- if (wp->yoff == 0) { /* top pane */
- if (wp == w->active)
- return (px <= wp->sx / 2);
- return (px > wp->sx / 2);
- }
- return (0);
- }
-
- /* Check if the pane covers the whole height. */
- if (wp->yoff == 0 && wp->sy == w->sy) {
- /* This can either be the left pane or the right pane. */
- if (wp->xoff == 0) { /* left pane */
- if (wp == w->active)
- return (py <= wp->sy / 2);
- return (py > wp->sy / 2);
- }
- return (0);
- }
-
- return (type);
-}
-
/* Redraw entire screen. */
void
screen_redraw_screen(struct client *c, int status_only, int borders_only)
@@ -283,14 +239,35 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
}
for (i = 0; i < tty->sx; i++) {
celltype = screen_redraw_get_cell_type(c, i, j, &wp);
- if (celltype == CELL_INSIDE)
+ if (celltype == CELL_INSIDE || celltype == CELL_OUTSIDE)
continue;
- borderrel = screen_redraw_get_border_rel(w->active, i, j);
- if (marktype == 1) /* colorsplit */
- tty_attributes(tty, screen_redraw_check_active_pane_indicator(i, j, celltype, w, wp) ? &active_gc : &other_gc);
- else
- tty_attributes(tty, borderrel != BORDER_NOT ? &active_gc : &other_gc);

+ /* Is this cell on the active pane border? */
+ borderrel = screen_redraw_get_border_rel(w->active, i, j);
+ switch (borderrel) {
+ case BORDER_LEFT:
+ case BORDER_RIGHT:
+ case BORDER_TOP:
+ case BORDER_BOTTOM:
+ if (marktype == 1 /* colorsplit */
+     /* If there are more than two panes, that's enough. */
+     && window_count_panes(w) == 2 && wp) {
+ if ((borderrel == BORDER_TOP && i >= wp->sx / 2) ||
+    (borderrel == BORDER_BOTTOM && i <= wp->sx / 2) ||
+    (borderrel == BORDER_LEFT && j >= wp->sy / 2) ||
+    (borderrel == BORDER_RIGHT && j <= wp->sy / 2)) {
+ tty_attributes(tty, &active_gc);
+ break;
+ }
+ else {
+ tty_attributes(tty, &other_gc);
+ break;
+ }
+ }
+ /* Fall through if not drawing colorsplit. */
+ default:
+ tty_attributes(tty, borderrel == BORDER_NOT ? &other_gc : &active_gc);
+ }
tty_cursor(tty, i, top + j);

if (marktype == 2 /* arrows */
--
1.8.4


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users