Commit Diff
Diff:
d5e0ee089932fa61ce56746c09c77019353d5614
6b91e1041d28dd381315414c359c84c2d1fa2d93
Commit:
6b91e1041d28dd381315414c359c84c2d1fa2d93
Tree:
7456a785593b51ba103a884cbcbe229fac6c3bdf
Author:
Omar Polo <op@omarpolo.com>
Date:
Sun Oct 9 16:17:51 2022 UTC
Message:
remove wrap_one, use an extra parameter for wrap_text
commit - d5e0ee089932fa61ce56746c09c77019353d5614
commit + 6b91e1041d28dd381315414c359c84c2d1fa2d93
blob - fcffadb7e89a7c3f8800eee0aacb3e232a4c4be0
blob + 8793d03eda3d404e665223439754a4253e93b1e3
--- include/telescope.h
+++ include/telescope.h
@@ -345,8 +345,7 @@ int wrap_one(struct buffer *, const char *, struct l
void erase_buffer(struct buffer *);
void empty_linelist(struct buffer*);
void empty_vlist(struct buffer*);
-int wrap_one(struct buffer *, const char *, struct line *, size_t);
-int wrap_text(struct buffer*, const char*, struct line*, size_t);
+int wrap_text(struct buffer*, const char*, struct line*, size_t, int);
int wrap_page(struct buffer *, int width);
#endif /* TELESCOPE_H */
blob - 7c359d32f7211243d1f277da709a91db6df22fde
blob + ad32a7ab8e92e8ec3a0888241258284f90dbc46a
--- u/wrap.c
+++ u/wrap.c
@@ -100,33 +100,6 @@ push_line(struct buffer *buffer, struct line *l, const
vl->flags = flags;
TAILQ_INSERT_TAIL(&buffer->head, vl, vlines);
- return 1;
-}
-
-/*
- * Similar to wrap_text, but emit only o vline.
- */
-int
-wrap_one(struct buffer *buffer, const char *prfx, struct line *l, size_t width)
-{
- struct vline *vl, *t;
-
- /*
- * be lazy: call wrap_text and then discard the continuations.
- */
-
- if (!wrap_text(buffer, prfx, l, width))
- return 0;
-
- TAILQ_FOREACH_SAFE(vl, &buffer->head, vlines, t) {
- if (vl->flags & L_CONTINUATION) {
- TAILQ_REMOVE(&buffer->head, vl, vlines);
- free(vl->line);
- free(vl);
- buffer->line_max--;
- }
- }
-
return 1;
}
@@ -135,7 +108,8 @@ wrap_text(struct buffer *buffer, const char *prfx, str
* that when printed will have a leading prefix prfx.
*/
int
-wrap_text(struct buffer *buffer, const char *prfx, struct line *l, size_t width)
+wrap_text(struct buffer *buffer, const char *prfx, struct line *l,
+ size_t width, int oneline)
{
const char *line, *space;
size_t ret, off, start, cur, prfxwidth;
@@ -170,6 +144,9 @@ wrap_text(struct buffer *buffer, const char *prfx, str
if (!push_line(buffer, l, &line[start], off - start, flags))
return 0;
+ if (oneline)
+ return 0;
+
flags = L_CONTINUATION;
start = off;
cur = t;
@@ -218,7 +195,8 @@ wrap_page(struct buffer *buffer, int width)
case LINE_PATCH_HUNK_HDR:
case LINE_PATCH_ADD:
case LINE_PATCH_DEL:
- wrap_text(buffer, prfx, l, MIN(fill_column, width));
+ wrap_text(buffer, prfx, l, MIN(fill_column, width),
+ 0);
break;
case LINE_COMPL:
case LINE_COMPL_CURRENT:
@@ -226,7 +204,7 @@ wrap_page(struct buffer *buffer, int width)
case LINE_DOWNLOAD:
case LINE_DOWNLOAD_DONE:
case LINE_DOWNLOAD_INFO:
- wrap_one(buffer, prfx, l, width);
+ wrap_text(buffer, prfx, l, width, 1);
break;
case LINE_FRINGE:
/* never, ever wrapped */
Omar Polo