Improve formatting
This commit is contained in:
parent
d1f2b6e25f
commit
014d2ab62c
|
@ -3,30 +3,17 @@
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int second = 0;
|
|
||||||
static char *buf = NULL;
|
static char *buf = NULL;
|
||||||
static size_t size = 0;
|
static size_t size = 0;
|
||||||
ssize_t len = 0;
|
long n = 1;
|
||||||
for (long n=1; (len = getline(&buf, &size, stdin)) > 0; n++)
|
while(getline(&buf, &size, stdin) > 0)
|
||||||
{
|
{
|
||||||
if (n < 5)
|
if (n++ < 5) /* overflow possible */
|
||||||
continue;
|
continue;
|
||||||
if (len && buf[len - 1] == '\n')
|
|
||||||
buf[len - 1] = '\0';
|
|
||||||
if (strncmp(buf,"-->", 3) == 0)
|
if (strncmp(buf,"-->", 3) == 0)
|
||||||
{
|
|
||||||
if (second)
|
|
||||||
{
|
|
||||||
second = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
second = 1;
|
else if (buf[0] != 10)
|
||||||
}
|
fputs(buf, stdout);
|
||||||
}
|
|
||||||
else if (buf[0] != 0) /* Don't print newline at EOF */
|
|
||||||
puts(buf);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
12
popup.c
12
popup.c
|
@ -62,7 +62,7 @@ int get_max_len(char *string, XftFont *font, int max_text_width)
|
||||||
eol--;
|
eol--;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < eol; i++)
|
for (int i = 0; i < MIN(eol+1, strlen(string)); i++)
|
||||||
if (string[i] == '\n')
|
if (string[i] == '\n')
|
||||||
{
|
{
|
||||||
string[i] = ' ';
|
string[i] = ' ';
|
||||||
|
@ -73,11 +73,9 @@ int get_max_len(char *string, XftFont *font, int max_text_width)
|
||||||
while (eol && (string[eol] & 0xC0) == 0x80)
|
while (eol && (string[eol] & 0xC0) == 0x80)
|
||||||
--eol;
|
--eol;
|
||||||
|
|
||||||
if (info.width <= max_text_width)
|
/* uncomment to always split at spaces */
|
||||||
return eol;
|
/* if (info.width <= max_text_width) */
|
||||||
|
/* return eol; */
|
||||||
|
|
||||||
/* prefer splitting at spaces */
|
|
||||||
/* int temp = eol; */
|
/* int temp = eol; */
|
||||||
/* while (string[eol] != ' ' && eol) */
|
/* while (string[eol] != ' ' && eol) */
|
||||||
/* --eol; */
|
/* --eol; */
|
||||||
|
@ -141,7 +139,7 @@ int main()
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
if (num_of_lines == 0)
|
if (num_of_lines == 0)
|
||||||
die("stdin is empty");
|
die("stdin is empty");
|
||||||
|
|
||||||
unsigned int text_height = font->ascent - font->descent;
|
unsigned int text_height = font->ascent - font->descent;
|
||||||
unsigned int height = (num_of_lines - 1) * line_spacing + num_of_lines * text_height + 2 * padding;
|
unsigned int height = (num_of_lines - 1) * line_spacing + num_of_lines * text_height + 2 * padding;
|
||||||
|
|
Loading…
Reference in a new issue