#define FOREGROUND_COLOR_BASE 30
#endif
+#ifndef FOREGROUND_DEFAULT_COLOR
+#define FOREGROUND_DEFAULT_COLOR 39
+#endif
+
#ifndef BACKGROUND_COLOR_BASE
#define BACKGROUND_COLOR_BASE 40
#endif
+#ifndef BACKGROUND_DEFAULT_COLOR
+#define BACKGROUND_DEFAULT_COLOR 49
+#endif
+
#ifndef TEXT_PALETTE_SIZE
#define TEXT_PALETTE_SIZE 48
#endif
display->background_color = color;
}
+void
+ply_text_display_reset_background_color (ply_text_display_t *display)
+{
+
+ ply_terminal_write (display->terminal,
+ COLOR_SEQUENCE_FORMAT,
+ BACKGROUND_DEFAULT_COLOR);
+
+ display->background_color = color;
+}
+
void
ply_text_display_set_foreground_color (ply_text_display_t *display,
ply_terminal_color_t color)
display->foreground_color = color;
}
+void
+ply_text_display_reset_foreground_color (ply_text_display_t *display)
+{
+ ply_terminal_write (display->terminal,
+ COLOR_SEQUENCE_FORMAT,
+ FOREGROUND_DEFAULT_COLOR);
+
+ display->foreground_color = color;
+}
+
ply_terminal_color_t
ply_text_display_get_background_color (ply_text_display_t *display)
{
#include "ply-label.h"
#include "ply-pixel-buffer.h"
#include "ply-utils.h"
+#include "ply-logger.h"
#include "script.h"
#include "script-parse.h"
#include "script-object.h"
script_lib_image_data_t *data = user_data;
ply_pixel_buffer_t *image;
ply_label_t *label;
- script_obj_t *alpha_obj, *font_obj;
+ script_obj_t *alpha_obj, *font_obj, *align_obj;
int width, height;
+ int align = PLY_LABEL_ALIGN_LEFT;
char *font;
char *text = script_obj_hash_get_string (state->local, "text");
script_obj_unref(font_obj);
+ align_obj = script_obj_hash_peek_element(state->local, "align");
+
+ if (script_obj_is_string(align_obj)) {
+ char *align_str = script_obj_as_string(align_obj);
+
+ if(!strcmp("left", align_str))
+ align = PLY_LABEL_ALIGN_LEFT;
+ else if(!strcmp("center", align_str))
+ align = PLY_LABEL_ALIGN_CENTER;
+ else if(!strcmp("right", align_str))
+ align = PLY_LABEL_ALIGN_RIGHT;
+ else
+ ply_error("Unrecognized Image.Text alignment string '%s'. "
+ "Expecting 'left', 'center', or 'right'\n",
+ align_str);
+ free(align_str);
+ }
+ script_obj_unref(align_obj);
+
if (!text) return script_return_obj_null ();
label = ply_label_new ();
ply_label_set_text (label, text);
if (font)
ply_label_set_font (label, font);
+ ply_label_set_alignment(label, align);
ply_label_set_color (label, red, green, blue, alpha);
ply_label_show (label, NULL, 0, 0);
"blue",
"alpha",
"font",
+ "align",
NULL);
script_obj_unref (image_hash);
return Image.Adopt (this._Scale(width, height));
};
-Image.Text = fun (text, red, green, blue, alpha, font)
+Image.Text = fun (text, red, green, blue, alpha, font, align)
{
- return Image.Adopt (Image._Text (text, red, green, blue, alpha, font));
+ return Image.Adopt (Image._Text (text, red, green, blue, alpha, font, align));
};
Image |= fun (filename)