Index: src/bisect.c ================================================================== --- src/bisect.c +++ src/bisect.c @@ -390,11 +390,11 @@ for(i=0; i +#ifdef _WIN32 +# include +#else +# include +#endif /* ** Given a comment string zText, format that string for printing ** on a TTY. Assume that the output cursors is indent spaces from ** the left margin and that a single line can contain no more than @@ -36,10 +41,27 @@ int doIndent = 0; char *zBuf; char zBuffer[400]; int lineCnt = 0; +#if defined(_WIN32) + if( lineLength<0 ){ + CONSOLE_SCREEN_BUFFER_INFO csbi; + memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); + if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ + tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent; + } + } +#elif defined(TIOCGWINSZ) + if( lineLength<0 ){ + struct winsize w; + memset(&w, 0, sizeof(struct winsize)); + if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ + tlen = w.ws_col - indent; + } + } +#endif if( zText==0 ) zText = "(NULL)"; if( tlen<=0 ){ tlen = strlen(zText); } if( tlen >= (sizeof(zBuffer)) ){ Index: src/descendants.c ================================================================== --- src/descendants.c +++ src/descendants.c @@ -356,11 +356,11 @@ width = atoi(zWidth); if( (width!=0) && (width<=39) ){ fossil_fatal("-W|--width value must be >39 or 0"); } }else{ - width = 79; + width = -1; } db_find_and_open_repository(0,0); if( recomputeFlag ) leaf_rebuild(); blob_zero(&sql); blob_append(&sql, timeline_query_for_tty(), -1); Index: src/finfo.c ================================================================== --- src/finfo.c +++ src/finfo.c @@ -146,16 +146,20 @@ /* this is the default, no-op */ } zLimit = find_option("limit","n",1); zWidth = find_option("width","W",1); iLimit = zLimit ? atoi(zLimit) : -1; - iWidth = zWidth ? atoi(zWidth) : 79; zOffset = find_option("offset",0,1); iOffset = zOffset ? atoi(zOffset) : 0; iBrief = (find_option("brief","b",0) == 0); - if( (iWidth!=0) && (iWidth<=22) ){ - fossil_fatal("-W|--width value must be >22 or 0"); + if( zWidth ){ + iWidth = atoi(zWidth); + if( (iWidth!=0) && (iWidth<=22) ){ + fossil_fatal("-W|--width value must be >22 or 0"); + } + }else{ + iWidth = -1; } if( g.argc!=3 ){ usage("?-l|--log? ?-b|--brief? FILENAME"); } file_tree_name(g.argv[2], &fname, 1); Index: src/info.c ================================================================== --- src/info.c +++ src/info.c @@ -132,11 +132,11 @@ fossil_print("tags: %s\n", zTags); } free(zTags); if( zComment ){ fossil_print("comment: "); - comment_print(zComment, 14, 79); + comment_print(zComment, 14, -1); free(zComment); } } /* Index: src/merge.c ================================================================== --- src/merge.c +++ src/merge.c @@ -47,11 +47,11 @@ indent-1, zLabel, db_column_text(&q, 3), db_column_text(&q, 1), db_column_text(&q, 0), indent, ""); - comment_print(zCom, indent, 78); + comment_print(zCom, indent, -1); fossil_free(zCom); } db_finalize(&q); } @@ -210,11 +210,11 @@ ); if( db_step(&q)==SQLITE_ROW ){ char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", db_column_text(&q, 0), db_column_text(&q, 1), db_column_text(&q, 3), db_column_text(&q, 2)); - comment_print(zCom, 0, 79); + comment_print(zCom, 0, -1); fossil_free(zCom); } db_finalize(&q); }else{ usage("?OPTIONS? ?VERSION?"); Index: src/name.c ================================================================== --- src/name.c +++ src/name.c @@ -582,11 +582,11 @@ default: zType = "Unknown"; break; } fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), db_column_text(&q, 1)); fossil_print("comment: "); - comment_print(db_column_text(&q,3), 12, 78); + comment_print(db_column_text(&q,3), 12, -1); } db_finalize(&q); /* Check to see if this object is used as a file in a check-in */ db_prepare(&q, @@ -604,11 +604,11 @@ fossil_print(" part of [%.10s] by %s on %s\n", db_column_text(&q, 1), db_column_text(&q, 3), db_column_text(&q, 2)); fossil_print(" "); - comment_print(db_column_text(&q,4), 12, 78); + comment_print(db_column_text(&q,4), 12, -1); } db_finalize(&q); /* Check to see if this object is used as an attachment */ db_prepare(&q, @@ -639,11 +639,11 @@ db_column_text(&q,7)); } fossil_print(" by user %s on %s\n", db_column_text(&q,2), db_column_text(&q,3)); fossil_print(" "); - comment_print(db_column_text(&q,1), 12, 78); + comment_print(db_column_text(&q,1), 12, -1); } db_finalize(&q); } /* Index: src/search.c ================================================================== --- src/search.c +++ src/search.c @@ -202,11 +202,11 @@ width = atoi(zWidth); if( (width!=0) && (width<=20) ){ fossil_fatal("-W|--width value must be >20 or 0"); } }else{ - width = 79; + width = -1; } db_must_be_within_tree(); if( g.argc<2 ) return; blob_init(&pattern, g.argv[2], -1); Index: src/stash.c ================================================================== --- src/stash.c +++ src/stash.c @@ -525,11 +525,11 @@ width = atoi(zWidth); if( (width!=0) && (width<=46) ){ fossil_fatal("-W|--width value must be >46 or 0"); } }else{ - width = 79; + width = -1; } if( !verboseFlag ){ verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ } verify_all_options(); Index: src/timeline.c ================================================================== --- src/timeline.c +++ src/timeline.c @@ -1780,11 +1780,11 @@ width = atoi(zWidth); if( (width!=0) && (width<=20) ){ fossil_fatal("-W|--width value must be >20 or 0"); } }else{ - width = 79; + width = -1; } zOffset = find_option("offset",0,1); iOffset = zOffset ? atoi(zOffset) : 0; if( g.argc>=4 ){ k = strlen(g.argv[2]); Index: src/tkt.c ================================================================== --- src/tkt.c +++ src/tkt.c @@ -1264,11 +1264,11 @@ fossil_print(" Change "); } fossil_print("%h: ",z); if( blob_size(&val)>50 || contains_newline(&val)) { fossil_print("\n ",blob_str(&val)); - comment_print(blob_str(&val),4,79); + comment_print(blob_str(&val),4,-1); }else{ fossil_print("%s\n",blob_str(&val)); } blob_reset(&val); }