Fossil SCM

Auto-adjust the with of timeline (and various other output places) according to real terminal width. Suggested by Baptiste Daroussin.

jan.nijtmans 2014-06-13 14:21 trunk
Commit c4891e24af9052db1ca824399baf468852ba9980
+2 -1
--- src/config.h
+++ src/config.h
@@ -49,19 +49,20 @@
4949
#include <stdarg.h>
5050
#include <assert.h>
5151
5252
#endif
5353
54
-#if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
54
+#if defined(__MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
5555
# if defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
5656
typedef int socklen_t;
5757
# endif
5858
# ifndef _WIN32
5959
# define _WIN32
6060
# endif
6161
#else
6262
# include <sys/types.h>
63
+# include <termios.h>
6364
# include <signal.h>
6465
# include <pwd.h>
6566
#endif
6667
6768
/*
6869
--- src/config.h
+++ src/config.h
@@ -49,19 +49,20 @@
49 #include <stdarg.h>
50 #include <assert.h>
51
52 #endif
53
54 #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
55 # if defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
56 typedef int socklen_t;
57 # endif
58 # ifndef _WIN32
59 # define _WIN32
60 # endif
61 #else
62 # include <sys/types.h>
 
63 # include <signal.h>
64 # include <pwd.h>
65 #endif
66
67 /*
68
--- src/config.h
+++ src/config.h
@@ -49,19 +49,20 @@
49 #include <stdarg.h>
50 #include <assert.h>
51
52 #endif
53
54 #if defined(__MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
55 # if defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
56 typedef int socklen_t;
57 # endif
58 # ifndef _WIN32
59 # define _WIN32
60 # endif
61 #else
62 # include <sys/types.h>
63 # include <termios.h>
64 # include <signal.h>
65 # include <pwd.h>
66 #endif
67
68 /*
69
--- src/descendants.c
+++ src/descendants.c
@@ -356,11 +356,17 @@
356356
width = atoi(zWidth);
357357
if( (width!=0) && (width<=39) ){
358358
fossil_fatal("-W|--width value must be >39 or 0");
359359
}
360360
}else{
361
+#ifdef TIOCGWINSZ
362
+ struct winsize w;
363
+ ioctl(0, TIOCGWINSZ, &w);
364
+ width = w.ws_col;
365
+#else
361366
width = 79;
367
+#endif
362368
}
363369
db_find_and_open_repository(0,0);
364370
if( recomputeFlag ) leaf_rebuild();
365371
blob_zero(&sql);
366372
blob_append(&sql, timeline_query_for_tty(), -1);
367373
--- src/descendants.c
+++ src/descendants.c
@@ -356,11 +356,17 @@
356 width = atoi(zWidth);
357 if( (width!=0) && (width<=39) ){
358 fossil_fatal("-W|--width value must be >39 or 0");
359 }
360 }else{
 
 
 
 
 
361 width = 79;
 
362 }
363 db_find_and_open_repository(0,0);
364 if( recomputeFlag ) leaf_rebuild();
365 blob_zero(&sql);
366 blob_append(&sql, timeline_query_for_tty(), -1);
367
--- src/descendants.c
+++ src/descendants.c
@@ -356,11 +356,17 @@
356 width = atoi(zWidth);
357 if( (width!=0) && (width<=39) ){
358 fossil_fatal("-W|--width value must be >39 or 0");
359 }
360 }else{
361 #ifdef TIOCGWINSZ
362 struct winsize w;
363 ioctl(0, TIOCGWINSZ, &w);
364 width = w.ws_col;
365 #else
366 width = 79;
367 #endif
368 }
369 db_find_and_open_repository(0,0);
370 if( recomputeFlag ) leaf_rebuild();
371 blob_zero(&sql);
372 blob_append(&sql, timeline_query_for_tty(), -1);
373
--- src/search.c
+++ src/search.c
@@ -202,11 +202,17 @@
202202
width = atoi(zWidth);
203203
if( (width!=0) && (width<=20) ){
204204
fossil_fatal("-W|--width value must be >20 or 0");
205205
}
206206
}else{
207
+#ifdef TIOCGWINSZ
208
+ struct winsize w;
209
+ ioctl(0, TIOCGWINSZ, &w);
210
+ width = w.ws_col;
211
+#else
207212
width = 79;
213
+#endif
208214
}
209215
210216
db_must_be_within_tree();
211217
if( g.argc<2 ) return;
212218
blob_init(&pattern, g.argv[2], -1);
213219
--- src/search.c
+++ src/search.c
@@ -202,11 +202,17 @@
202 width = atoi(zWidth);
203 if( (width!=0) && (width<=20) ){
204 fossil_fatal("-W|--width value must be >20 or 0");
205 }
206 }else{
 
 
 
 
 
207 width = 79;
 
208 }
209
210 db_must_be_within_tree();
211 if( g.argc<2 ) return;
212 blob_init(&pattern, g.argv[2], -1);
213
--- src/search.c
+++ src/search.c
@@ -202,11 +202,17 @@
202 width = atoi(zWidth);
203 if( (width!=0) && (width<=20) ){
204 fossil_fatal("-W|--width value must be >20 or 0");
205 }
206 }else{
207 #ifdef TIOCGWINSZ
208 struct winsize w;
209 ioctl(0, TIOCGWINSZ, &w);
210 width = w.ws_col;
211 #else
212 width = 79;
213 #endif
214 }
215
216 db_must_be_within_tree();
217 if( g.argc<2 ) return;
218 blob_init(&pattern, g.argv[2], -1);
219
+7 -1
--- src/stash.c
+++ src/stash.c
@@ -525,11 +525,17 @@
525525
width = atoi(zWidth);
526526
if( (width!=0) && (width<=46) ){
527527
fossil_fatal("-W|--width value must be >46 or 0");
528528
}
529529
}else{
530
- width = 79;
530
+#ifdef TIOCGWINSZ
531
+ struct winsize w;
532
+ ioctl(0, TIOCGWINSZ, &w);
533
+ width = w.ws_col;
534
+#else
535
+ width = 79;
536
+#endif
531537
}
532538
if( !verboseFlag ){
533539
verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
534540
}
535541
verify_all_options();
536542
--- src/stash.c
+++ src/stash.c
@@ -525,11 +525,17 @@
525 width = atoi(zWidth);
526 if( (width!=0) && (width<=46) ){
527 fossil_fatal("-W|--width value must be >46 or 0");
528 }
529 }else{
530 width = 79;
 
 
 
 
 
 
531 }
532 if( !verboseFlag ){
533 verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
534 }
535 verify_all_options();
536
--- src/stash.c
+++ src/stash.c
@@ -525,11 +525,17 @@
525 width = atoi(zWidth);
526 if( (width!=0) && (width<=46) ){
527 fossil_fatal("-W|--width value must be >46 or 0");
528 }
529 }else{
530 #ifdef TIOCGWINSZ
531 struct winsize w;
532 ioctl(0, TIOCGWINSZ, &w);
533 width = w.ws_col;
534 #else
535 width = 79;
536 #endif
537 }
538 if( !verboseFlag ){
539 verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
540 }
541 verify_all_options();
542
--- src/timeline.c
+++ src/timeline.c
@@ -1780,11 +1780,17 @@
17801780
width = atoi(zWidth);
17811781
if( (width!=0) && (width<=20) ){
17821782
fossil_fatal("-W|--width value must be >20 or 0");
17831783
}
17841784
}else{
1785
+#ifdef TIOCGWINSZ
1786
+ struct winsize w;
1787
+ ioctl(0, TIOCGWINSZ, &w);
1788
+ width = w.ws_col;
1789
+#else
17851790
width = 79;
1791
+#endif
17861792
}
17871793
zOffset = find_option("offset",0,1);
17881794
iOffset = zOffset ? atoi(zOffset) : 0;
17891795
if( g.argc>=4 ){
17901796
k = strlen(g.argv[2]);
17911797
--- src/timeline.c
+++ src/timeline.c
@@ -1780,11 +1780,17 @@
1780 width = atoi(zWidth);
1781 if( (width!=0) && (width<=20) ){
1782 fossil_fatal("-W|--width value must be >20 or 0");
1783 }
1784 }else{
 
 
 
 
 
1785 width = 79;
 
1786 }
1787 zOffset = find_option("offset",0,1);
1788 iOffset = zOffset ? atoi(zOffset) : 0;
1789 if( g.argc>=4 ){
1790 k = strlen(g.argv[2]);
1791
--- src/timeline.c
+++ src/timeline.c
@@ -1780,11 +1780,17 @@
1780 width = atoi(zWidth);
1781 if( (width!=0) && (width<=20) ){
1782 fossil_fatal("-W|--width value must be >20 or 0");
1783 }
1784 }else{
1785 #ifdef TIOCGWINSZ
1786 struct winsize w;
1787 ioctl(0, TIOCGWINSZ, &w);
1788 width = w.ws_col;
1789 #else
1790 width = 79;
1791 #endif
1792 }
1793 zOffset = find_option("offset",0,1);
1794 iOffset = zOffset ? atoi(zOffset) : 0;
1795 if( g.argc>=4 ){
1796 k = strlen(g.argv[2]);
1797

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button