[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[giFTcurs-commits] giFTcurs/src format.c misc.c screen.h ui_draw.c...
From: |
Christian Häggström |
Subject: |
[giFTcurs-commits] giFTcurs/src format.c misc.c screen.h ui_draw.c... |
Date: |
Sat, 18 Oct 2003 09:20:11 -0400 |
CVSROOT: /cvsroot/giftcurs
Module name: giFTcurs
Branch:
Changes by: Christian Häggström <address@hidden> 03/10/18 09:20:11
Modified files:
src : format.c misc.c screen.h ui_draw.c ui_main.c
ui_transfer.c
Log message:
Made the \v color changer char to a symbolic constant instead.
Patches:
Index: giFTcurs/src/format.c
diff -u giFTcurs/src/format.c:1.69 giFTcurs/src/format.c:1.70
--- giFTcurs/src/format.c:1.69 Fri Oct 17 12:38:59 2003
+++ giFTcurs/src/format.c Sat Oct 18 09:20:09 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: format.c,v 1.69 2003/10/17 16:38:59 saturn Exp $
+ * $Id: format.c,v 1.70 2003/10/18 13:20:09 saturn Exp $
*/
#include "giftcurs.h"
@@ -148,7 +148,6 @@
} text;
struct {
int color;
- int bold;
} color;
format_t macro;
struct {
@@ -551,13 +550,15 @@
format_unref(fixedpos);
return NULL;
}
+ color++; /* List starts at 0,
but colors at 1 */
}
if (progress_on) {
DEBUG("Colors not allowed inside
{progress}{endprogress}");
} else {
pos = new_node(COLOR, pos);
+ if (args)
+ color |= COLOR_BOLD;
pos->u.color.color = color;
- pos->u.color.bold = !!args;
}
} else if (command[0] == '$') {
/* we have a macro to expand */
@@ -865,9 +866,8 @@
}
/* Fill str with the actual data. All rendering info is provided in k */
-/* TODO: The color_stack could be a GString */
static int format_produce(format_t n, struct format_ctrl *k, GString *str, int
produced,
- dynarray *color_stack)
+ GString *color_stack)
{
int progress_mark_visual = -1;
int progress_mark_offset = -1;
@@ -1010,35 +1010,32 @@
start += progress_mark_offset;
end += progress_mark_offset;
/* reset to the previous color */
- if (color_stack->num)
- color =
GPOINTER_TO_INT(list_index(color_stack, color_stack->num - 1));
+ if (color_stack->len)
+ color =
color_stack->str[color_stack->len - 1];
else
- color = 0; /* {standard} */
- g_string_insert_c(str, end, '\v');
- g_string_insert_c(str, end + 1, 'a' + color);
- g_string_insert_c(str, start, '\v');
- g_string_insert_c(str, start + 1, 'a' +
COLOR_PROGRESS - 1);
+ color = COLOR_STANDARD; /* {standard} */
+ g_string_insert_c(str, end, COLOR_SELECT_CHAR);
+ g_string_insert_c(str, end + 1, color);
+ g_string_insert_c(str, start,
COLOR_SELECT_CHAR);
+ g_string_insert_c(str, start + 1,
COLOR_PROGRESS | COLOR_SPECIAL);
progress_mark_visual = -1;
}
break;
case COLOR:
- g_string_append_c(str, '\v');
color = n->u.color.color;
if (color == -1) {
/* pop a color from the stack */
- if (color_stack->num)
- dynarray_pop(color_stack);
- if (color_stack->num)
- color =
GPOINTER_TO_INT(list_index(color_stack, color_stack->num - 1));
+ if (color_stack->len)
+ g_string_truncate(color_stack,
color_stack->len - 1);
+ if (color_stack->len)
+ color =
color_stack->str[color_stack->len - 1];
else
- color = 0; /* quietly fallback to
{standard} */
+ color = COLOR_STANDARD; /* quietly
fallback to {standard} */
} else {
- dynarray_append(color_stack,
GINT_TO_POINTER(color));
+ g_string_append_c(color_stack, color);
}
- if (n->u.color.bold)
- g_string_append_c(str, 'A' + color);
- else
- g_string_append_c(str, 'a' + color);
+ g_string_append_c(str, COLOR_SELECT_CHAR);
+ g_string_append_c(str, color);
break;
case SPACE:
width = k->space_len / k->spaces;
@@ -1079,7 +1076,7 @@
struct format_counters c;
GString str = { 0 };
int slack;
- dynarray color_stack = { 0 };
+ GString color_stack = { 0 };
morot.getattr = getattr;
morot.udata = udata;
@@ -1103,7 +1100,7 @@
/* Fill the string with actual stuff */
format_produce(format, &morot, &str, 0, &color_stack);
- dynarray_removeall(&color_stack);
+ g_free(color_stack.str);
/*DEBUG("planned length %d, actual lenght %d", maxlen,
vstrlen(str.str)); */
return str.str;
Index: giFTcurs/src/misc.c
diff -u giFTcurs/src/misc.c:1.43 giFTcurs/src/misc.c:1.44
--- giFTcurs/src/misc.c:1.43 Tue Jul 22 20:26:25 2003
+++ giFTcurs/src/misc.c Sat Oct 18 09:20:10 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: misc.c,v 1.43 2003/07/23 00:26:25 weinholt Exp $
+ * $Id: misc.c,v 1.44 2003/10/18 13:20:10 saturn Exp $
*/
#include "giftcurs.h"
@@ -32,6 +32,8 @@
#include "list.h"
#include "parse.h"
+#include "screen.h" /* XXX for coloring of messages
*/
+
static const int STATS_INTERVAL = 5000; /* 5 seconds */
gift_stat stats = { 0, 0, 0, 0, 0, 0 };
@@ -262,7 +264,8 @@
g_message(_("There is an important message from the daemon! Check the
console."));
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,
- "\vn%s\va\n%s", _("And now a few words from our sponsor:"),
msg);
+ "%c%c%s%c%c\n%s", COLOR_SELECT_CHAR, COLOR_HIT_BAD,
+ _("And now a few words from our sponsor:"),
COLOR_SELECT_CHAR, COLOR_STANDARD, msg);
}
void sharing_toggle(void)
Index: giFTcurs/src/screen.h
diff -u giFTcurs/src/screen.h:1.79 giFTcurs/src/screen.h:1.80
--- giFTcurs/src/screen.h:1.79 Wed Oct 15 21:35:56 2003
+++ giFTcurs/src/screen.h Sat Oct 18 09:20:10 2003
@@ -18,35 +18,44 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: screen.h,v 1.79 2003/10/16 01:35:56 weinholt Exp $
+ * $Id: screen.h,v 1.80 2003/10/18 13:20:10 saturn Exp $
*/
#ifndef _SCREEN_H
#define _SCREEN_H
/* If you change/extend this list, change also the strings in screen.c */
enum colors {
- COLOR_STANDARD = 1, /* "\va" */
- COLOR_HEADER, /* "\vb" */
- COLOR_SEARCH_BOX, /* "\vc" */
- COLOR_RESULT_BOX, /* "\vd" */
- COLOR_STAT_BOX, /* "\ve" */
- COLOR_STAT_DATA, /* "\vf" */
- COLOR_STAT_DATA_BAD, /* "\vg" */
- COLOR_INFO_BOX, /* "\vh" */
- COLOR_DOWNLOAD_BOX, /* "\vi" */
- COLOR_UPLOAD_BOX, /* "\vj" */
- COLOR_HELP_BOX, /* "\vk" */
- COLOR_CONSOLE_BOX, /* "\vl" */
- COLOR_HIT_GOOD, /* "\vn" */
- COLOR_HIT_BAD, /* "\vn" */
- COLOR_PROGRESS, /* "\vo" */
- COLOR_TOTAL_PROGRESS, /* "\vp" */
+ COLOR_STANDARD = 1,
+ COLOR_HEADER,
+ COLOR_SEARCH_BOX,
+ COLOR_RESULT_BOX,
+ COLOR_STAT_BOX,
+ COLOR_STAT_DATA,
+ COLOR_STAT_DATA_BAD,
+ COLOR_INFO_BOX,
+ COLOR_DOWNLOAD_BOX,
+ COLOR_UPLOAD_BOX,
+ COLOR_HELP_BOX,
+ COLOR_CONSOLE_BOX,
+ COLOR_HIT_GOOD,
+ COLOR_HIT_BAD,
+ COLOR_PROGRESS,
+ COLOR_TOTAL_PROGRESS,
COLOR_DIAMOND,
COLOR_SELECTION,
COLOR_BUTTON_BAR,
COLOR_BUTTON_BAR_SEL,
COLOR_BUTTON_BAR_ALERT,
- ITEMS_NUM = COLOR_BUTTON_BAR_ALERT
+ ITEMS_NUM = COLOR_BUTTON_BAR_ALERT,
+
+ /* Strings that are drawn with draw_fmt_str can change color on the text
+ * by embed an COLOR_SELECT_CHAR followed by the color number, possibly
+ * or'ed with the following constants. */
+ /* This should be an unused char that is filtered in input */
+ COLOR_SELECT_CHAR = '\v',
+ COLOR_BOLD = 0200,
+ COLOR_SPECIAL = 0100, /* used for progress bars */
+ COLOR_MASK = 077,
};
extern int max_x, max_y;
Index: giFTcurs/src/ui_draw.c
diff -u giFTcurs/src/ui_draw.c:1.111 giFTcurs/src/ui_draw.c:1.112
--- giFTcurs/src/ui_draw.c:1.111 Tue Oct 14 15:47:59 2003
+++ giFTcurs/src/ui_draw.c Sat Oct 18 09:20:10 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_draw.c,v 1.111 2003/10/14 19:47:59 weinholt Exp $
+ * $Id: ui_draw.c,v 1.112 2003/10/18 13:20:10 saturn Exp $
*/
#include "giftcurs.h"
@@ -85,7 +85,7 @@
int draw_input(int x, int y, int w, const char *header, const char *value, int
attr)
{
int p;
- int print; /* This is how many columns from "value" we can print */
+ int print; /* This is how many
columns from "value" we can print */
move(y, x);
if (header) {
@@ -99,7 +99,7 @@
addch('[');
getyx(stdscr, y, p);
attrset(COLOR_PAIR(COLOR_STAT_DATA));
- hline('_', x + w - p - 1); /* Trailing '_' */
+ hline('_', x + w - p - 1); /* Trailing '_' */
move(y, x + w - 1);
attrset(attr);
addch(']');
@@ -150,17 +150,15 @@
attrset(selection_color(selected, COLOR_STANDARD));
for (u = str; *u && printed < w; u++) {
- if (*u == '\v') {
+ if (*u == COLOR_SELECT_CHAR) {
u++;
- if (*u == '4')
- attrset(selection_color_special(selected,
COLOR_PROGRESS));
- else if (*u == '5')
- attrset(selection_color_special(selected,
COLOR_TOTAL_PROGRESS));
- else if ('a' <= *u && *u < 'a' + ITEMS_NUM)
- attrset(selection_color(selected, *u - 'a' +
1));
- else if ('A' <= *u && *u < 'A' + ITEMS_NUM) {
- attrset(selection_color(selected, *u - 'A' +
1));
+ if (*u & COLOR_SPECIAL) {
+ attrset(selection_color_special(selected, *u &
COLOR_MASK));
+ } else if (*u & COLOR_BOLD) {
+ attrset(selection_color(selected, *u &
COLOR_MASK));
attron(A_BOLD);
+ } else {
+ attrset(selection_color(selected, *u &
COLOR_MASK));
}
continue;
}
Index: giFTcurs/src/ui_main.c
diff -u giFTcurs/src/ui_main.c:1.348 giFTcurs/src/ui_main.c:1.349
--- giFTcurs/src/ui_main.c:1.348 Thu Oct 16 20:59:26 2003
+++ giFTcurs/src/ui_main.c Sat Oct 18 09:20:10 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_main.c,v 1.348 2003/10/17 00:59:26 weinholt Exp $
+ * $Id: ui_main.c,v 1.349 2003/10/18 13:20:10 saturn Exp $
*/
#include "giftcurs.h"
@@ -132,7 +132,7 @@
misc_init();
for (i = 0; i < G_N_ELEMENTS(realms); i++)
- list_append(&search_realm, g_strdup(_(realms[i])));
+ list_append(&search_realm, _(realms[i]));
search_realm.sel = 0;
active_field = 0;
@@ -182,7 +182,7 @@
gift_unregister(NULL, (EventCallback) detach_handle, NULL);
g_free(slash_search_term.str);
g_free(search_term.str);
- list_free_entries(&search_realm);
+ list_remove_all(&search_realm);
gift_search_cleanup();
format_unref(hit_fmt);
format_unref(subhit_fmt);
@@ -655,6 +655,10 @@
move(curs_y, curs_x);
}
+#define HEADER_FMT(extra_fmt, header) \
+ "%c%c%s:%c%c " extra_fmt, COLOR_SELECT_CHAR, COLOR_HEADER | COLOR_BOLD,
\
+ header, COLOR_SELECT_CHAR, COLOR_STANDARD
+
static void make_the_extra_info(hit *allan)
{
subhit *sh;
@@ -666,14 +670,14 @@
list_free_entries(&allan->infobox);
/* Size: */
- s = g_strdup_printf("\vB%s:\va %u %s", _("Size"), allan->filesize,
+ s = g_strdup_printf(HEADER_FMT("%u %s", _("Size")), allan->filesize,
ngettext("byte", "bytes",
allan->filesize));
wrap_lines(&allan->infobox, s, width);
g_free(s);
/* User: */
users = g_string_new("");
- g_string_printf(users, "\vB%s:\va ", _("User"));
+ g_string_printf(users, HEADER_FMT("", _("User")));
for (i = 0; i < tree_children(allan)->num; i++) {
sh = list_index(tree_children(allan), i);
g_string_append_printf(users, i < tree_children(allan)->num - 1
? "%s, " : "%s", sh->user);
@@ -682,20 +686,20 @@
g_string_free(users, TRUE);
/* Path: */
- s = g_strdup_printf("\vB%s:\va %s", _("Path"), allan->directory);
+ s = g_strdup_printf(HEADER_FMT("%s", _("Path")), allan->directory);
wrap_lines(&allan->infobox, s, width);
g_free(s);
/* Hash: */
if (allan->hash) {
- s = g_strdup_printf("\vB%s:\va %s", _("Hash"), allan->hash);
+ s = g_strdup_printf(HEADER_FMT("%s", _("Hash")), allan->hash);
wrap_lines(&allan->infobox, s, width);
g_free(s);
}
/* Mime: */
if (allan->mime) {
- s = g_strdup_printf("\vB%s:\va %s", _("Mime"), allan->mime);
+ s = g_strdup_printf(HEADER_FMT("%s", _("Mime")), allan->mime);
wrap_lines(&allan->infobox, s, width);
g_free(s);
}
@@ -704,7 +708,7 @@
for (i = 0; i < allan->metadata.num; i++) {
metadata *metarn = list_index(&allan->metadata, i);
- s = g_strdup_printf("\vB%s:\va %s", _(metarn->key),
metarn->data);
+ s = g_strdup_printf(HEADER_FMT("%s", _(metarn->key)),
metarn->data);
wrap_lines(&allan->infobox, s, width);
g_free(s);
}
Index: giFTcurs/src/ui_transfer.c
diff -u giFTcurs/src/ui_transfer.c:1.255 giFTcurs/src/ui_transfer.c:1.256
--- giFTcurs/src/ui_transfer.c:1.255 Tue Sep 23 15:50:34 2003
+++ giFTcurs/src/ui_transfer.c Sat Oct 18 09:20:10 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_transfer.c,v 1.255 2003/09/23 19:50:34 weinholt Exp $
+ * $Id: ui_transfer.c,v 1.256 2003/10/18 13:20:10 saturn Exp $
*/
#include "giftcurs.h"
@@ -413,7 +413,9 @@
for (i = 0; i < G_N_ELEMENTS(help) && x1 < max_x; i++) {
char buf[100];
- g_snprintf(buf, sizeof buf, "\vB%c\va - %s", help[i].key,
_(help[i].desc));
+ g_snprintf(buf, sizeof buf, "%c%c%c%c%c - %s",
COLOR_SELECT_CHAR,
+ COLOR_HEADER | COLOR_BOLD, help[i].key,
COLOR_SELECT_CHAR,
+ COLOR_STANDARD, _(help[i].desc));
w1 = vstrlen(buf) - 4; /* do not count invisible characters */
draw_fmt_str(x1, DOWNLOAD_H, max_x - x1, 0, buf);
mouse_register(x1, DOWNLOAD_H, w1, 1, BUTTON1_PRESSED,
ui_mouse_simulate_keypress,
@@ -489,7 +491,7 @@
h = UPLOAD_H;
active_field = FIELD_UPLOADS;
} else
- g_assert_not_reached();
+ assert_not_reached();
if (ry == 0)
foo->sel -= h;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [giFTcurs-commits] giFTcurs/src format.c misc.c screen.h ui_draw.c...,
Christian Häggström <=