Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Initial draft of the ability to break a multi-line comment on word boundaries using the new algorithm. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | experimental |
Files: | files | file ages | folders |
SHA1: |
10b47cc35082b1a9102af5b6425e66e5 |
User & Date: | mistachkin 2014-06-20 03:56:04.865 |
Context
2014-06-20
| ||
18:31 | Further refinements and more tests. ... (check-in: 70ba07c3 user: mistachkin tags: experimental) | |
03:56 | Initial draft of the ability to break a multi-line comment on word boundaries using the new algorithm. ... (check-in: 10b47cc3 user: mistachkin tags: experimental) | |
2014-06-19
| ||
21:30 | Merge updates from trunk. ... (check-in: 5d2a7a0f user: mistachkin tags: experimental) | |
Changes
Changes to src/bisect.c.
︙ | ︙ | |||
388 389 390 391 392 393 394 | if( g.argc==3 ){ unsigned int i; for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ char *z = mprintf("bisect-%s", aBisectOption[i].zName); fossil_print(" %-15s %-6s ", aBisectOption[i].zName, db_lget(z, (char*)aBisectOption[i].zDefault)); fossil_free(z); | | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | if( g.argc==3 ){ unsigned int i; for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ char *z = mprintf("bisect-%s", aBisectOption[i].zName); fossil_print(" %-15s %-6s ", aBisectOption[i].zName, db_lget(z, (char*)aBisectOption[i].zDefault)); fossil_free(z); comment_print(aBisectOption[i].zDesc, 27, -1, COMMENT_PRINT_DEFAULT); } }else if( g.argc==4 || g.argc==5 ){ unsigned int i; n = strlen(g.argv[3]); for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){ char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
︙ | ︙ |
Changes to src/comformat.c.
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <assert.h> #ifdef _WIN32 # include <windows.h> #else # include <termios.h> #endif /* ** This is the previous value used by most external callers when they ** needed to specify a default maximum line length to be used with the ** comment_print() function. */ #ifndef COMMENT_LEGACY_LINE_LENGTH # define COMMENT_LEGACY_LINE_LENGTH (78) | > > > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <assert.h> #ifdef _WIN32 # include <windows.h> #else # include <termios.h> #endif #if INTERFACE #define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */ #define COMMENT_PRINT_WORD_BREAK ((u32)0x00000001) /* Break lines on words. */ #define COMMENT_PRINT_DEFAULT COMMENT_PRINT_NONE /* Default flags. */ #endif /* ** This is the previous value used by most external callers when they ** needed to specify a default maximum line length to be used with the ** comment_print() function. */ #ifndef COMMENT_LEGACY_LINE_LENGTH # define COMMENT_LEGACY_LINE_LENGTH (78) |
︙ | ︙ | |||
47 48 49 50 51 52 53 | ** 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 ** width characters. Indent all subsequent lines by indent. ** ** Return the number of newlines that are output. */ | | > > > > > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | ** 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 ** width characters. Indent all subsequent lines by indent. ** ** Return the number of newlines that are output. */ int comment_print( const char *zText, /* The comment text to be printed. */ int indent, /* Number of spaces to indent each non-initial line. */ int width, /* Maximum number of characters per line. */ int flags /* Zero or more "COMMENT_PRINT_*" flags, see above. */ ){ int maxChars = width - indent; int lineCnt = 0; const char *zLine; #if defined(_WIN32) if( width<0 ){ CONSOLE_SCREEN_BUFFER_INFO csbi; |
︙ | ︙ | |||
90 91 92 93 94 95 96 | if( zText[0]==0 ){ fossil_print("\n"); lineCnt++; return lineCnt; } zLine = zText; for(;;){ | | > | > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | if( zText[0]==0 ){ fossil_print("\n"); lineCnt++; return lineCnt; } zLine = zText; for(;;){ comment_print_line(zLine, zLine>zText ? indent : 0, maxChars, flags & COMMENT_PRINT_WORD_BREAK, &lineCnt, &zLine); if( !zLine || !zLine[0] ) break; } return lineCnt; } /* ** This function prints one logical line of a comment, stopping when it hits ** a new line -OR- runs out of space on the logical line. */ void comment_print_line( const char *zLine, /* [in] The comment line to print. */ int indent, /* [in] Number of spaces to indent, zero for none. */ int lineChars, /* [in] Maximum number of characters to print. */ int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */ int *pLineCnt, /* [in/out] Pointer to the total line count. */ const char **pzLine /* [out] Pointer to the end of the logical line. */ ){ int index = 0, charCnt = 0, lineCnt = 0, maxChars; if( !zLine ) return; if( lineChars<=0 ) return; comment_print_indent(zLine, indent, &index); |
︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | }else if( c=='\t' ){ charCnt++; if( maxChars<COMMENT_TAB_WIDTH ){ fossil_print(" "); break; } maxChars -= COMMENT_TAB_WIDTH; }else{ charCnt++; maxChars--; } fossil_print("%c", c); if( maxChars==0 ) break; if( c=='\n' ) break; | > > > > > > > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | }else if( c=='\t' ){ charCnt++; if( maxChars<COMMENT_TAB_WIDTH ){ fossil_print(" "); break; } maxChars -= COMMENT_TAB_WIDTH; }else if( wordBreak && fossil_isspace(c) ){ int nextIndex = comment_next_space(zLine, index); if( nextIndex<=0 || (nextIndex-index)>maxChars ){ break; } charCnt++; maxChars--; }else{ charCnt++; maxChars--; } fossil_print("%c", c); if( maxChars==0 ) break; if( c=='\n' ) break; |
︙ | ︙ | |||
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | if( zLine && piIndex ){ int index = *piIndex; while( fossil_isspace(zLine[index]) ){ index++; } *piIndex = index; } } } /* ** ** COMMAND: test-comment-format ** ** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH? ** ** Test comment formatting and printing. Use for testing only. ** ** Options: ** --decode Decode the text using the same method used when ** handling the value of a C-card from a manifest. */ void test_comment_format(void){ const char *zPrefix; char *zText; int indent, width; int decode = find_option("decode", 0, 0)!=0; if( g.argc!=4 && g.argc!=5 ){ usage("PREFIX TEXT ?WIDTH?"); } zPrefix = g.argv[2]; if( decode ){ zText = mprintf("%s", g.argv[3]); defossilize(zText); }else{ zText = g.argv[3]; } indent = strlen(zPrefix); if( g.argc==5 ){ width = atoi(g.argv[4]); }else{ width = -1; /* automatic */ } if( indent>0 ){ fossil_print("%s", zPrefix); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | if( zLine && piIndex ){ int index = *piIndex; while( fossil_isspace(zLine[index]) ){ index++; } *piIndex = index; } } } /* ** This function scans the specified comment line starting just after the ** initial index and returns the index of the next spacing character -OR- ** zero if such a character cannot be found. */ int comment_next_space( const char *zLine, /* [in] The comment line being printed. */ int index /* [in] The current character index being handled. */ ){ int nextIndex = index + 1; for(;;){ char c = zLine[nextIndex]; if( c==0 ){ return 0; } if( fossil_isspace(c) ){ return nextIndex; } nextIndex++; } return 0; /* NOT REACHED */ } /* ** ** COMMAND: test-comment-format ** ** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH? ** ** Test comment formatting and printing. Use for testing only. ** ** Options: ** --decode Decode the text using the same method used when ** handling the value of a C-card from a manifest. ** --wordbreak Attempt to break lines on word boundaries. */ void test_comment_format(void){ const char *zPrefix; char *zText; int indent, width; int decode = find_option("decode", 0, 0)!=0; int flags = COMMENT_PRINT_DEFAULT; if( find_option("wordbreak", 0, 0) ){ flags |= COMMENT_PRINT_WORD_BREAK; } if( g.argc!=4 && g.argc!=5 ){ usage("PREFIX TEXT ?WIDTH?"); } zPrefix = g.argv[2]; if( decode ){ zText = mprintf("%s", g.argv[3]); defossilize(zText); }else{ zText = g.argv[3]; } indent = strlen(zPrefix); if( g.argc==5 ){ width = atoi(g.argv[4]); }else{ width = -1; /* automatic */ } if( indent>0 ){ fossil_print("%s", zPrefix); } fossil_print("(%d lines output)\n", comment_print(zText, indent, width, flags)); if( zText!=g.argv[3] ) fossil_free(zText); } |
Changes to src/descendants.c.
︙ | ︙ | |||
391 392 393 394 395 396 397 | fossil_free(zLastBr); zLastBr = fossil_strdup(zBr); } n++; sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); fossil_print("%6s ", zLineNo); z = mprintf("%s [%.10s] %s", zDate, zId, zCom); | | | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | fossil_free(zLastBr); zLastBr = fossil_strdup(zBr); } n++; sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); fossil_print("%6s ", zLineNo); z = mprintf("%s [%.10s] %s", zDate, zId, zCom); comment_print(z, 7, width, COMMENT_PRINT_DEFAULT); fossil_free(z); } fossil_free(zLastBr); db_finalize(&q); } /* |
︙ | ︙ |
Changes to src/finfo.c.
︙ | ︙ | |||
199 200 201 202 203 204 205 | char *zOut; if( zBr==0 ) zBr = "trunk"; if( iBrief ){ fossil_print("%s ", zDate); zOut = sqlite3_mprintf( "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)", zCiUuid, zCom, zUser, zFileUuid, zBr); | | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | char *zOut; if( zBr==0 ) zBr = "trunk"; if( iBrief ){ fossil_print("%s ", zDate); zOut = sqlite3_mprintf( "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)", zCiUuid, zCom, zUser, zFileUuid, zBr); comment_print(zOut, 11, iWidth, COMMENT_PRINT_DEFAULT); sqlite3_free(zOut); }else{ blob_reset(&line); blob_appendf(&line, "%.10s ", zCiUuid); blob_appendf(&line, "%.10s ", zDate); blob_appendf(&line, "%8.8s ", zUser); blob_appendf(&line, "%8.8s ", zBr); blob_appendf(&line,"%-39.39s", zCom ); comment_print(blob_str(&line), 0, iWidth, COMMENT_PRINT_DEFAULT); } } db_finalize(&q); blob_reset(&fname); } } |
︙ | ︙ |
Changes to src/info.c.
︙ | ︙ | |||
130 131 132 133 134 135 136 | zTags = info_tags_of_checkin(rid, 0); if( zTags && zTags[0] ){ fossil_print("tags: %s\n", zTags); } free(zTags); if( zComment ){ fossil_print("comment: "); | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | zTags = info_tags_of_checkin(rid, 0); if( zTags && zTags[0] ){ fossil_print("tags: %s\n", zTags); } free(zTags); if( zComment ){ fossil_print("comment: "); comment_print(zComment, 14, -1, COMMENT_PRINT_DEFAULT); free(zComment); } } /* ** Print information about the URLs used to access a repository and ** checkouts in a repository. |
︙ | ︙ |
Changes to src/merge.c.
︙ | ︙ | |||
45 46 47 48 49 50 51 | } fossil_print("%-*s [%S] by %s on %s\n%*s", indent-1, zLabel, db_column_text(&q, 3), db_column_text(&q, 1), db_column_text(&q, 0), indent, ""); | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | } fossil_print("%-*s [%S] by %s on %s\n%*s", indent-1, zLabel, db_column_text(&q, 3), db_column_text(&q, 1), db_column_text(&q, 0), indent, ""); comment_print(zCom, indent, -1, COMMENT_PRINT_DEFAULT); fossil_free(zCom); } db_finalize(&q); } /* |
︙ | ︙ | |||
208 209 210 211 212 213 214 | " WHERE event.objid=%d AND blob.rid=%d", timeline_utc(), mid, mid ); 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)); | | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | " WHERE event.objid=%d AND blob.rid=%d", timeline_utc(), mid, mid ); 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, -1, COMMENT_PRINT_DEFAULT); fossil_free(zCom); } db_finalize(&q); }else{ usage("?OPTIONS? ?VERSION?"); return; } |
︙ | ︙ |
Changes to src/name.c.
︙ | ︙ | |||
580 581 582 583 584 585 586 | case 't': zType = "Ticket-change"; break; case 'g': zType = "Tag-change"; break; 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: "); | | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | case 't': zType = "Ticket-change"; break; case 'g': zType = "Tag-change"; break; 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, -1, COMMENT_PRINT_DEFAULT); } db_finalize(&q); /* Check to see if this object is used as a file in a check-in */ db_prepare(&q, "SELECT filename.name, blob.uuid, datetime(event.mtime%s)," " coalesce(euser,user), coalesce(ecomment,comment)" |
︙ | ︙ | |||
602 603 604 605 606 607 608 | while( db_step(&q)==SQLITE_ROW ){ fossil_print("file: %s\n", db_column_text(&q,0)); 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(" "); | | | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | while( db_step(&q)==SQLITE_ROW ){ fossil_print("file: %s\n", db_column_text(&q,0)); 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, -1, COMMENT_PRINT_DEFAULT); } db_finalize(&q); /* Check to see if this object is used as an attachment */ db_prepare(&q, "SELECT attachment.filename," " attachment.comment," |
︙ | ︙ | |||
637 638 639 640 641 642 643 | }else{ fossil_print(" via %s\n", 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(" "); | | | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | }else{ fossil_print(" via %s\n", 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, -1, COMMENT_PRINT_DEFAULT); } db_finalize(&q); } /* ** COMMAND: whatis* ** Usage: %fossil whatis NAME |
︙ | ︙ |
Changes to src/stash.c.
︙ | ︙ | |||
550 551 552 553 554 555 556 | stashid, db_column_text(&q, 1), db_column_text(&q, 3) ); zCom = db_column_text(&q, 2); if( zCom && zCom[0] ){ fossil_print(" "); | | | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | stashid, db_column_text(&q, 1), db_column_text(&q, 3) ); zCom = db_column_text(&q, 2); if( zCom && zCom[0] ){ fossil_print(" "); comment_print(zCom, 7, width, COMMENT_PRINT_DEFAULT); } if( verboseFlag ){ db_bind_int(&q2, "$id", stashid); while( db_step(&q2)==SQLITE_ROW ){ int isAdded = db_column_int(&q2, 0); int isRemoved = db_column_int(&q2, 1); const char *zOrig = db_column_text(&q2, 2); |
︙ | ︙ |
Changes to src/timeline.c.
︙ | ︙ | |||
1608 1609 1610 1611 1612 1613 1614 | n = strlen(zPrefix); } if( fossil_strcmp(zCurrentUuid,zId)==0 ){ sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); n += strlen(zPrefix); } zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); | > | | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 | n = strlen(zPrefix); } if( fossil_strcmp(zCurrentUuid,zId)==0 ){ sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); n += strlen(zPrefix); } zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); /* record another X lines */ nLine += comment_print(zFree, 9, width, COMMENT_PRINT_DEFAULT); sqlite3_free(zFree); if(verboseFlag){ if( !fchngQueryInit ){ db_prepare(&fchngQuery, "SELECT (pid==0) AS isnew," " (fid==0) AS isdel," |
︙ | ︙ |
Changes to src/tkt.c.
︙ | ︙ | |||
1262 1263 1264 1265 1266 1267 1268 | z++; }else{ fossil_print(" Change "); } fossil_print("%h: ",z); if( blob_size(&val)>50 || contains_newline(&val)) { fossil_print("\n ",blob_str(&val)); | | | 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 | z++; }else{ 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,-1,COMMENT_PRINT_DEFAULT); }else{ fossil_print("%s\n",blob_str(&val)); } blob_reset(&val); } } manifest_destroy(pTicket); |
︙ | ︙ |
Changes to test/comment.test.
︙ | ︙ | |||
76 77 78 79 80 81 82 | fossil test-comment-format "HH:MM:SS " ".....................................................................*" 78 test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} ############################################################################### fossil test-comment-format "*TEST* " "this\tis a test." 26 test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"} | > > > > > > > > > > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | fossil test-comment-format "HH:MM:SS " ".....................................................................*" 78 test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} ############################################################################### fossil test-comment-format "*TEST* " "this\tis a test." 26 test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"} ############################################################################### fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60 test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"} ############################################################################### fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |