X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstyle.c;h=76ef5d78a3d83b22f06977bf60badd861cdcb755;hb=77d5b31de1338fd87f67ab5896287519c8efe8ff;hp=80b66d6f2517f2e1129b73f37bf573764416bdc0;hpb=ae1a5770d142aa0900f1a4d4c7e7732a38aaafa9;p=rodin%2Fchimara.git
diff --git a/libchimara/style.c b/libchimara/style.c
index 80b66d6..76ef5d7 100644
--- a/libchimara/style.c
+++ b/libchimara/style.c
@@ -22,9 +22,9 @@ GtkTextTag* gtk_text_tag_copy(GtkTextTag *tag);
* @styl: The style to apply
*
* Changes the style of the current output stream. @styl should be one of the
- * style_ constants listed above. However, any value is actually
- * legal; if the interpreter does not recognize the style value, it will treat
- * it as %style_Normal.
+ * style_ constants. However, any value is actually legal; if the
+ * interpreter does not recognize the style value, it will treat it as
+ * %style_Normal.
*
* This policy allows for the future definition of styles without breaking old
* Glk libraries.
@@ -288,8 +288,6 @@ style_init(ChimaraGlk *glk)
/* Set the current style to a copy of the default style */
copy_default_styles_to_current_styles(glk);
-
- text_tag_to_attr_list(pager_tag, priv->pager_attr_list);
}
/* Reset style tables to the library's internal defaults */
@@ -307,6 +305,9 @@ copy_default_styles_to_current_styles(ChimaraGlk *glk)
CHIMARA_GLK_USE_PRIVATE(glk, priv);
g_hash_table_foreach(priv->default_styles->text_grid, style_table_copy, priv->current_styles->text_grid);
g_hash_table_foreach(priv->default_styles->text_buffer, style_table_copy, priv->current_styles->text_buffer);
+
+ GtkTextTag *pager_tag = GTK_TEXT_TAG( g_hash_table_lookup(priv->default_styles->text_buffer, "pager") );
+ text_tag_to_attr_list(pager_tag, priv->pager_attr_list);
}
/* Create the CSS file scanner */
@@ -780,7 +781,7 @@ query_tag(GtkTextTag *tag, glui32 wintype, glui32 hint)
* @val: The style hint. The meaning of this depends on @hint.
*
* Sets a hint about the appearance of one style for a particular type of
- * window. You can also set wintype to %wintype_AllTypes, which sets a hint for
+ * window. You can also set @wintype to %wintype_AllTypes, which sets a hint for
* all types of window.
*
* There is no equivalent constant to set a hint for all styles of a single
@@ -810,9 +811,9 @@ glk_stylehint_set(glui32 wintype, glui32 styl, glui32 hint, glsi32 val)
* @styl: The style to set a hint for.
* @hint: The type of style hint, one of the stylehint_ constants.
*
- * Resets a hint about the appearance of one style for a particular type of
- * window to it's default value. You can also set wintype to %wintype_AllTypes, which resets a hint for
- * all types of window.
+ * Clears a hint about the appearance of one style for a particular type of
+ * window to its default value. You can also set @wintype to %wintype_AllTypes,
+ * which clears a hint for all types of window.
*
* There is no equivalent constant to reset a hint for all styles of a single
* window type.
@@ -843,12 +844,20 @@ glk_stylehint_clear(glui32 wintype, glui32 styl, glui32 hint)
* @styl1: The first style to be distinguished from the second style.
* @styl2: The second style to be distinguished from the first style.
*
- * Returns: TRUE if the two styles are visually distinguishable in the given window.
- * If they are not, it returns FALSE.
+ * Decides whether two styles are visually distinguishable in the given window.
+ * The exact meaning of this is left for the library to determine.
+ * Chimara
+ * Currently, all styles of one window are assumed to be mutually
+ * distinguishable.
+ *
+ *
+ * Returns: %TRUE (1) if the two styles are visually distinguishable. If they
+ * are not, it returns %FALSE (0).
*/
glui32
glk_style_distinguish(winid_t win, glui32 styl1, glui32 styl2)
{
+ /* FIXME */
return styl1 != styl2;
}
@@ -859,7 +868,66 @@ glk_style_distinguish(winid_t win, glui32 styl1, glui32 styl2)
* @hint: The stylehint to measure.
* @result: Address to write the result to.
*
- * This function can be used to query the current value of a particular style hint.
+ * Tries to test an attribute of one style in the given window @win. The library
+ * may not be able to determine the attribute; if not, this returns %FALSE (0).
+ * If it can, it returns %TRUE (1) and stores the value in the location pointed
+ * at by @result.
+ *
+ * As usual, it is legal for @result to be %NULL, although fairly pointless.
+ *
+ *
+ * The meaning of the value depends on the hint which was tested:
+ *
+ *
+ * %stylehint_Indentation, %stylehint_ParaIndentation
+ * The indentation and paragraph indentation. These are in a
+ * metric which is platform-dependent.
+ * Most likely either characters or pixels.
+ *
+ *
+ *
+ * %stylehint_Justification
+ * One of the constants %stylehint_just_LeftFlush,
+ * %stylehint_just_LeftRight, %stylehint_just_Centered, or
+ * %stylehint_just_RightFlush.
+ *
+ *
+ * %stylehint_Size
+ * The font size. Again, this is in a platform-dependent
+ * metric.
+ * Pixels, points, or simply 1 if the library does not support
+ * varying font sizes.
+ *
+ *
+ *
+ * %stylehint_Weight
+ * 1 for heavy-weight fonts (boldface), 0 for normal weight,
+ * and -1 for light-weight fonts.
+ *
+ *
+ * %stylehint_Oblique
+ * 1 for oblique fonts (italic), or 0 for normal angle.
+ *
+ *
+ *
+ * %stylehint_Proportional
+ * 1 for proportional-width fonts, or 0 for fixed-width.
+ *
+ *
+ *
+ * %stylehint_TextColor, %stylehint_BackColor
+ * These are values from 0x00000000 to 0x00FFFFFF, encoded as
+ * described in Suggesting the
+ * Appearance of Styles.
+ *
+ *
+ * %stylehint_ReverseColor
+ * 0 for normal printing, 1 if the foreground and background
+ * colors are reversed.
+ *
+ *
+ *
* Returns: TRUE upon successul retrieval, otherwise FALSE.
*/
glui32
@@ -871,11 +939,13 @@ glk_style_measure(winid_t win, glui32 styl, glui32 hint, glui32 *result)
switch(win->type) {
case wintype_TextBuffer:
tag = g_hash_table_lookup( glk_data->current_styles->text_buffer, get_tag_name(styl) );
- *result = query_tag(tag, win->type, hint);
+ if(result)
+ *result = query_tag(tag, win->type, hint);
break;
case wintype_TextGrid:
tag = g_hash_table_lookup( glk_data->current_styles->text_grid, get_tag_name(styl) );
- *result = query_tag(tag, win->type, hint);
+ if(result)
+ *result = query_tag(tag, win->type, hint);
default:
return FALSE;
}