Changeset 6045ecf in mainline
- Timestamp:
- 2011-08-21T10:28:01Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f737c1d5
- Parents:
- 19d007e
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/help/help.c
r19d007e r6045ecf 153 153 "To learn more please point your browser to the HelenOS User's " 154 154 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n", 155 ALIGN_JUSTIFY);155 ALIGN_LEFT); 156 156 } 157 157 -
uspace/lib/fmtutil/fmtutil.c
r19d007e r6045ecf 60 60 } 61 61 62 static int print_line(wchar_t *wstr, size_t chars, void *data) 63 { 64 //char *line = wstr_to_astr(wstr); 62 /** Line consumer that prints the lines aligned according to spec 63 * 64 **/ 65 static int print_line(wchar_t *wstr, size_t chars, bool last, void *data) 66 { 65 67 printmode_t *pm = (printmode_t *) data; 66 //if (line == NULL) { 67 // return ENOMEM; 68 //} 68 wchar_t old_char = wstr[chars]; 69 69 wstr[chars] = 0; 70 return print_aligned_w(wstr, pm->width, pm->alignment); 71 //printf("%s", line); 72 //if (pm->newline_always || chars < pm->width) 73 // printf("\n"); 74 //free(line); 75 //return EOK; 70 int rc = print_aligned_w(wstr, pm->width, last, pm->alignment); 71 wstr[chars] = old_char; 72 return rc; 76 73 } 77 74 … … 91 88 } 92 89 93 int print_aligned_w(const wchar_t *wstr, size_t width, align_mode_t mode) 90 int print_aligned_w(const wchar_t *wstr, size_t width, bool last, 91 align_mode_t mode) 94 92 { 95 93 size_t i; 96 94 size_t len = wstr_length(wstr); 97 if (mode == ALIGN_LEFT ) {95 if (mode == ALIGN_LEFT || (mode == ALIGN_JUSTIFY && last)) { 98 96 for (i = 0; i < width; i++) { 99 97 if (i < len) … … 171 169 return EOK; 172 170 } 173 int print_aligned(const char *str, size_t width, align_mode_t mode)171 int print_aligned(const char *str, size_t width, bool last, align_mode_t mode) 174 172 { 175 173 wchar_t *wstr = str_to_awstr(str); … … 177 175 return ENOMEM; 178 176 } 179 int rc = print_aligned_w(wstr, width, mode);177 int rc = print_aligned_w(wstr, width, last, mode); 180 178 free(wstr); 181 179 return rc; 182 180 } 183 181 184 /**185 */186 182 int wrap(wchar_t *wstr, size_t width, line_consumer_fn consumer, void *data) 187 183 { … … 202 198 while (wstr[pos] == ' ' || wstr[pos] == '\n') { 203 199 if (wstr[pos] == '\n') { 204 consumer(wstr + line_start, line_len, data); 200 consumer(wstr + line_start, line_len, true, 201 data); 205 202 last_word_end = line_start = pos + 1; 206 203 line_len = 0; … … 213 210 wstr[pos] != '\n') 214 211 pos++; 212 bool last = wstr[pos] == 0; 215 213 /* Check if the line still fits width */ 216 214 if (pos - line_start > width) { 217 215 if (line_len > 0) 218 consumer(wstr + line_start, line_len, data); 216 consumer(wstr + line_start, line_len, last, 217 data); 219 218 line_start = last_word_end = word_start; 220 219 line_len = 0; … … 222 221 /* Check if we need to force wrap of long word*/ 223 222 if (pos - word_start > width) { 224 consumer(wstr + word_start, width, data);223 consumer(wstr + word_start, width, last, data); 225 224 pos = line_start = last_word_end = word_start + width; 226 225 line_len = 0; … … 233 232 */ 234 233 if (pos - line_start > 0) 235 consumer(wstr + line_start, pos - line_start, data);234 consumer(wstr + line_start, pos - line_start, true, data); 236 235 237 236 return EOK; -
uspace/lib/fmtutil/fmtutil.h
r19d007e r6045ecf 39 39 * @param content pointer to line data (note: this is NOT null-terminated) 40 40 * @param size number of characters in line 41 * @param end_of_para true if the line is the last line of the paragraph 41 42 * @param data user data 42 43 * 43 44 * @returns EOK on success or error code on failure 44 45 */ 45 typedef int (*line_consumer_fn)(wchar_t *, size_t, void *);46 typedef int (*line_consumer_fn)(wchar_t *, size_t, bool, void *); 46 47 47 extern int print_aligned_w(const wchar_t *, size_t, align_mode_t);48 extern int print_aligned(const char *, size_t, align_mode_t);48 extern int print_aligned_w(const wchar_t *, size_t, bool, align_mode_t); 49 extern int print_aligned(const char *, size_t, bool, align_mode_t); 49 50 extern int print_wrapped(const char *, size_t, align_mode_t); 50 51 extern int print_wrapped_console(const char *, align_mode_t);
Note:
See TracChangeset
for help on using the changeset viewer.