@@ -207,6 +207,7 @@ static double opt_exit_status_threshold = 1.0;
207207#if USE_NCURSES
208208static int opt_show_graph = 1 ;
209209static int opt_utf8 = 0 ;
210+ static int opt_columns = 1 ;
210211#endif
211212static char * opt_outfile = NULL ;
212213static int opt_bell = 0 ;
@@ -655,7 +656,7 @@ static int read_options (int argc, char **argv) /* {{{ */
655656 {
656657 optchar = getopt (argc , argv , "46c:hi:I:t:Q:f:D:Z:O:P:m:w:b"
657658#if USE_NCURSES
658- "uUg:"
659+ "uUg:C: "
659660#endif
660661 );
661662
@@ -791,6 +792,16 @@ static int read_options (int argc, char **argv) /* {{{ */
791792 case 'U' :
792793 opt_utf8 = 1 ;
793794 break ;
795+ case 'C' :
796+ {
797+ int new_columns = atoi (optarg );
798+ if (new_columns > 0 )
799+ opt_columns = new_columns ;
800+ else
801+ fprintf (stderr , "Ignoring invalid number of columns: %s\n" ,
802+ optarg );
803+ break ;
804+ }
794805#endif
795806 case 'b' :
796807 opt_bell = 1 ;
@@ -1281,7 +1292,11 @@ static int on_resize (pingobj_t *ping) /* {{{ */
12811292 if ((height < 1 ) || (width < 1 ))
12821293 return (EINVAL );
12831294
1284- main_win_height = height - (box_height * host_num );
1295+ int box_rows_count = host_num / opt_columns ;
1296+ if (box_rows_count < 1 )
1297+ box_rows_count = 1 ;
1298+
1299+ main_win_height = height - (box_height * box_rows_count );
12851300 wresize (main_win , main_win_height , /* width = */ width );
12861301 /* Allow scrolling */
12871302 scrollok (main_win , TRUE);
@@ -1290,6 +1305,8 @@ static int on_resize (pingobj_t *ping) /* {{{ */
12901305 idlok (main_win , TRUE);
12911306 wrefresh (main_win );
12921307
1308+ width = width / opt_columns ;
1309+
12931310 for (iter = ping_iterator_get (ping );
12941311 iter != NULL ;
12951312 iter = ping_iterator_next (iter ))
@@ -1307,8 +1324,8 @@ static int on_resize (pingobj_t *ping) /* {{{ */
13071324 }
13081325 context -> window = newwin (/* height = */ box_height ,
13091326 /* width = */ width ,
1310- /* y = */ main_win_height + (box_height * context -> index ),
1311- /* x = */ 0 );
1327+ /* y = */ main_win_height + (box_height * ( context -> index / opt_columns ) ),
1328+ /* x = */ width * ( context -> index % opt_columns ) );
13121329 }
13131330
13141331 return (0 );
@@ -1368,7 +1385,11 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */
13681385 init_pair (OPING_RED_HIST , COLOR_RED , COLOR_YELLOW );
13691386 }
13701387
1371- main_win_height = height - (box_height * host_num );
1388+ int box_rows_count = host_num / opt_columns ;
1389+ if (box_rows_count < 1 )
1390+ box_rows_count = 1 ;
1391+
1392+ main_win_height = height - (box_height * box_rows_count );
13721393 main_win = newwin (/* height = */ main_win_height ,
13731394 /* width = */ width ,
13741395 /* y = */ 0 , /* x = */ 0 );
@@ -1380,6 +1401,8 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */
13801401 wmove (main_win , /* y = */ main_win_height - 1 , /* x = */ 0 );
13811402 wrefresh (main_win );
13821403
1404+ width = width / opt_columns ;
1405+
13831406 for (iter = ping_iterator_get (ping );
13841407 iter != NULL ;
13851408 iter = ping_iterator_next (iter ))
@@ -1397,8 +1420,8 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */
13971420 }
13981421 context -> window = newwin (/* height = */ box_height ,
13991422 /* width = */ width ,
1400- /* y = */ main_win_height + (box_height * context -> index ),
1401- /* x = */ 0 );
1423+ /* y = */ main_win_height + (box_height * ( context -> index / opt_columns ) ),
1424+ /* x = */ width * ( context -> index % opt_columns ) );
14021425 }
14031426
14041427
0 commit comments