#include <gdk-pixbuf/gdk-pixbuf.h>
#include "floating_shape.h"
+#include "display_cow.h"
#include "settings.h"
#include "i18n.h"
return bubble_tidy(&bubble);
}
-GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height)
+GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height, cowmode_t mode)
{
bubble_t bubble;
int text_width, text_height;
pango_layout_set_font_description(layout, font);
pango_layout_set_text(layout, stripped, -1);
pango_layout_get_pixel_size(layout, &text_width, &text_height);
+
+ bubble_style_t style = mode == COWMODE_NORMAL ? NORMAL : THOUGHT;
- bubble_size_from_content(&bubble, NORMAL, text_width, text_height);
+ bubble_size_from_content(&bubble, style, text_width, text_height);
*p_width = bubble.width;
*p_height = bubble.height;
- bubble_init(&bubble, NORMAL);
+ bubble_init(&bubble, style);
// Render the text
gdk_draw_layout(bubble.pixmap, bubble.gc,
#include "settings.h"
#include "i18n.h"
-GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height);
+GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height, cowmode_t mode);
GdkPixbuf *make_dream_bubble(const char *file, int *p_width, int *p_height);
#define TICK_TIMEOUT 100
return words;
}
-static void normal_setup(const char *text, bool debug)
+static void normal_setup(const char *text, bool debug, cowmode_t mode)
{
char *text_copy = strdup(text);
}
xcowsay.bubble_pixbuf = make_text_bubble(text_copy, &xcowsay.bubble_width,
- &xcowsay.bubble_height);
+ &xcowsay.bubble_height, mode);
free(text_copy);
}
{
switch (mode) {
case COWMODE_NORMAL:
- normal_setup(text, debug);
+ case COWMODE_THINK:
+ normal_setup(text, debug, mode);
break;
case COWMODE_DREAM:
dream_setup(text, debug);
static int daemon_flag = 0;
static int debug = 0;
+static int think_flag = 0;
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"time", required_argument, 0, 't'},
{"font", required_argument, 0, 'f'},
{"dream", required_argument, 0, 'd'},
+ {"think", no_argument, &think_flag, 1},
{"cow-size", required_argument, 0, 'c'},
{"reading-speed", required_argument, 0, 'r'},
{"daemon", no_argument, &daemon_flag, 1},
{0, 0, 0, 0}
};
-static void read_from_stdin(void)
+static void read_from_stdin(cowmode_t mode)
{
char *data = malloc(MAX_STDIN);
size_t n = fread(data, 1, MAX_STDIN, stdin);
}
data[n] = '\0';
- display_cow_or_invoke_daemon(debug, data, COWMODE_NORMAL);
+ display_cow_or_invoke_daemon(debug, data, mode);
free(data);
}
" -r, --reading-speed=N\t%s\n"
" -f, --font=FONT\t%s\n"
" -d, --dream=FILE\t%s\n"
+ " --think\t\t%s\n"
" --daemon\t\t%s\n"
" --cow-size=SIZE\t%s\n"
" --debug\t\t%s\n\n"
i18n("Number of milliseconds to delay per word."),
i18n("Set message font (Pango format)."),
i18n("Display an image instead of text."),
+ i18n("Display a thought bubble rather than a speech bubble."),
i18n("Run xcowsay in daemon mode."),
i18n("Size of the cow (small, med, large)."),
i18n("Keep daemon attached to terminal."),
srand((unsigned)time(NULL));
+ cowmode_t mode = think_flag ? COWMODE_THINK : COWMODE_NORMAL;
+
if (daemon_flag) {
run_cowsay_daemon(debug, argc, argv);
}
display_cow_or_invoke_daemon(debug, dream_file, COWMODE_DREAM);
}
else if (optind == argc) {
- read_from_stdin();
+ read_from_stdin(mode);
}
else {
char *str = cat_from_index(optind, argc, argv);
- display_cow_or_invoke_daemon(debug, str, COWMODE_NORMAL);
+ display_cow_or_invoke_daemon(debug, str, mode);
free(str);
}
}