[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: o_text_basic.nw
User: cnieves
Date: 06/02/27 12:53:03
Modified: . o_text_basic.nw
Log:
Added the text overbar feature.
Revision Changes Path
1.25 +121 -12 eda/geda/devel/libgeda/noweb/o_text_basic.nw
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_text_basic.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/noweb/o_text_basic.nw,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- o_text_basic.nw 14 Mar 2005 12:10:32 -0000 1.24
+++ o_text_basic.nw 27 Feb 2006 17:53:03 -0000 1.25
@@ -444,7 +444,8 @@
int size_of_tab_in_coord;
OBJECT *o_font_set;
gchar *ptr;
-
+ gunichar previous_char;
+ gunichar c = 0;
if (string == NULL) {
return 0;
}
@@ -466,8 +467,17 @@
ptr != NULL && *ptr != 0;
ptr = g_utf8_find_next_char (ptr, NULL))
{
- gunichar c = g_utf8_get_char_validated (ptr, -1);
+ previous_char = c;
+ c = g_utf8_get_char_validated (ptr, -1);
+ if ( (c == (gunichar) '\\') &&
+ (previous_char != (gunichar) '\\') ) {
+ continue;
+ }
+ if ( (c == (gunichar) '_') &&
+ (previous_char == (gunichar) '\\') ) {
+ continue;
+ }
switch (c) {
case ((gunichar)'\n'):
width = 0;
@@ -528,8 +538,15 @@
int char_height;
int line_start_x, line_start_y;
int sign=1;
+ int overbar_startx=0, overbar_starty=0;
+ int overbar_endx=0, overbar_endy=0;
+ int overbar_height_offset = 0;
+ int last_char_width;
+ gboolean overbar_started = FALSE;
gchar *ptr;
+ gchar *aux_string;
OBJECT *o_font_set;
+ gunichar c=0, previous_char = 0;
temp_list = object_list;
@@ -702,8 +719,16 @@
for (ptr = string;
ptr != NULL && *ptr != 0;
+ previous_char =
+ g_utf8_get_char_validated (ptr, -1),
ptr = g_utf8_find_next_char (ptr, NULL)) {
- gunichar c = g_utf8_get_char_validated (ptr, -1);
+ /* Keep track of the previous character and its width.
+ They will be used in the overbar and escape characters */
+ aux_string = g_strdup_printf("%c", previous_char);
+ last_char_width = o_text_width(w_current, aux_string, size/2);
+ g_free(aux_string);
+
+ c = g_utf8_get_char_validated (ptr, -1);
o_font_set = g_hash_table_lookup (font_loaded, GUINT_TO_POINTER (c));
if (o_font_set == NULL) {
@@ -733,15 +758,99 @@
o_text_width(w_current, TAB_CHAR_MODEL, size/2);
if (c != '\n' && c != '\t') {
- /* only add the character if it is not a newline or tab character */
+ /* only add the character if it is not a newline, a tab character
+ a escape character or the overbar delimiter escape sequence.
+ Add it if it is the escaped escape character */
+ if ( ( (c != '\\') &&
+ (!(previous_char == '\\' && c == '_')) ) ||
+ (previous_char == '\\' && c == '\\') ) {
temp_list = o_list_copy_all(w_current,
o_font_set->font_prim_objs->next,
temp_list, NORMAL_FLAG);
+ }
if (start_of_char != NULL)
start_of_char = start_of_char->next;
}
- /* if the character is a newline or tab, this code will "continue" */
+ if ( (c == '_' && previous_char == '\\') ||
+ (c == '\n' && overbar_started) ||
+ (previous_char == '\n' && overbar_started) ) {
+ /* Found the overbar delimiter sequence
+ If the character is the newline and the overbar was started,
+ then end it and start it again in the next character, after
+ processing the newline. */
+ overbar_height_offset = char_height + (char_height >> 2);
+ if ( (!overbar_started) ||
+ (overbar_started && previous_char == '\n') ){
+ /* Start point of the overbar */
+ overbar_started = TRUE;
+ switch (angle) {
+ case 0:
+ overbar_startx = x_offset;
+ overbar_starty = y_offset + overbar_height_offset;
+ break;
+ case 90:
+ overbar_startx = x_offset - overbar_height_offset;
+ overbar_starty = y_offset;
+ break;
+ case 180:
+ overbar_startx = x_offset;
+ overbar_starty = y_offset - overbar_height_offset;
+ break;
+ case 270:
+ overbar_startx = x_offset + overbar_height_offset;
+ overbar_starty = y_offset;
+ break;
+ default:
+ fprintf(stderr, "o_text_create_string: Angle not supported\n");
+ break;
+ }
+ } else {
+ /* Then this is the end point of the overbar */
+ switch (angle) {
+ case 0:
+ overbar_endx = x_offset - last_char_width;
+ overbar_endy = y_offset + overbar_height_offset;
+ break;
+ case 90:
+ overbar_endx = x_offset - overbar_height_offset;
+ overbar_endy = y_offset - last_char_width;
+ break;
+ case 180:
+ overbar_endx = x_offset + last_char_width;
+ overbar_endy = y_offset - overbar_height_offset;
+ break;
+ case 270:
+ overbar_endx = x_offset + overbar_height_offset;
+ overbar_endy = y_offset + last_char_width;
+ break;
+ default:
+ fprintf(stderr, "o_text_create_string: Angle not supported\n");
+ break;
+ }
+ /* Now add the overbar (if it is not a zero length overbar) */
+ if ( (overbar_startx != overbar_endx) ||
+ (overbar_starty != overbar_endy) ) {
+ temp_list = o_line_add(w_current, temp_list, OBJ_LINE, color,
+ overbar_startx, overbar_starty,
+ overbar_endx, overbar_endy);
+ }
+
+ if (!((c == '\n') && (overbar_started))) {
+ /* If it's the newline character, keep the overbar started, since
+ we have to end this one & start another one in the next line */
+ overbar_started = FALSE;
+ }
+ }
+ }
+
+ /* Do nothing with special characters */
+ if ( (c == '\\' && previous_char != '\\') ||
+ (c == '_' && previous_char == '\\') ) {
+ continue;
+ }
+
+ /* If the character is a newline or tab, this code will "continue" */
switch (c) {
case '\n':
switch (angle) {