summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e52a5de)
raw | patch | inline | side by side (parent: e52a5de)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Tue, 27 Feb 2007 15:20:31 +0000 (16:20 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 28 Feb 2007 01:29:02 +0000 (17:29 -0800) |
Now, it returns the current column, does not add a newline, and you can
pass a negative indent, to indicate that the indent was already printed.
With this, you can actually continue in the middle of a paragraph, not
having to print everything into a buffer first.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
pass a negative indent, to indicate that the indent was already printed.
With this, you can actually continue in the middle of a paragraph, not
having to print everything into a buffer first.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
utf8.c | patch | blob | history | |
utf8.h | patch | blob | history |
index 7c80eeccb4537ab6d4387941c6262c89cab30d33..ea23a6e5dc60bc3683c98a01f9a4e7dd8c7efb18 100644 (file)
--- a/utf8.c
+++ b/utf8.c
/*
* Wrap the text, if necessary. The variable indent is the indent for the
* first line, indent2 is the indent for all other lines.
+ * If indent is negative, assume that already -indent columns have been
+ * consumed (and no extra indent is necessary for the first line).
*/
-void print_wrapped_text(const char *text, int indent, int indent2, int width)
+int print_wrapped_text(const char *text, int indent, int indent2, int width)
{
int w = indent, assume_utf8 = is_utf8(text);
const char *bol = text, *space = NULL;
+ if (indent < 0) {
+ w = -indent;
+ space = text;
+ }
+
for (;;) {
char c = *text;
if (!c || isspace(c)) {
else
print_spaces(indent);
fwrite(start, text - start, 1, stdout);
- if (!c) {
- putchar('\n');
- return;
- } else if (c == '\t')
+ if (!c)
+ return w;
+ else if (c == '\t')
w |= 0x07;
space = text;
w++;
text++;
}
}
+ return w;
}
int is_encoding_utf8(const char *name)
index a07c5a88af63d41ae963f230510a33d78b68a525..15db6f1f27ef7a1f056d5b6adca901f092036f82 100644 (file)
--- a/utf8.h
+++ b/utf8.h
int is_utf8(const char *text);
int is_encoding_utf8(const char *name);
-void print_wrapped_text(const char *text, int indent, int indent2, int len);
+int print_wrapped_text(const char *text, int indent, int indent2, int len);
#ifndef NO_ICONV
char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding);