gtk GtkTextView 使用尝试

本文介绍了GTK+中的GtkTextView组件,它用于显示GtkTextBuffer中的文本。GtkTextBuffer作为文本框正文的缓冲区,通过GtkTextIter定位文字位置,而GtkTextMark保存位置不受修改影响。GtkTextTag用于设置文本标记,改变文字样式。通过gtk_text_buffer_create_tag ()创建标签,并应用到指定区域。此外,还提及了自定义主题和相关资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



GtkTextView:代表了窗口中可见的文本框,用来显示GtkTextBuffer.
GtkTextBuffer:文本框正文的缓冲区,文本框文字的插入、删除都是对这一类变量进行操作。
GtkTextIter:保存文字在buffer中位置的结构。
GtkTextMark:A position in the buffer preserved across buffer modifications
GtkTextTag:用来给指定的文字添加一些标记,改变指定区域的文字的显示效果。如:字体的颜色、大小的改变。
GtkTextTagTable:是GtkTextTag标记的集合表。

GtkTextIter — Text buffer iterator



  GtkWidget *view;
  GtkTextBuffer *buffer;
  GtkTextIter start, end;
  GtkTextIter iter;

  • GtkTextTag

所有可以设置的tag 属性参见https://developer.gnome.org/gtk3/stable/GtkTextTag.html

  "direction"                GtkTextDirection      : Read / Write
  "editable"                 gboolean              : Read / Write
  "editable-set"             gboolean              : Read / Write
  "family"                   gchar*                : Read / Write
  "family-set"               gboolean              : Read / Write
  "font"                     gchar*                : Read / Write
  "font-desc"                PangoFontDescription*  : Read / Write
  "foreground"               gchar*                : Write
  "foreground-gdk"           GdkColor*             : Read / Write
  "foreground-rgba"          GdkRGBA*              : Read / Write
  "foreground-set"           gboolean              : Read / Write
  "indent"                   gint                  : Read / Write
  "indent-set"               gboolean              : Read / Write
  "invisible"                gboolean              : Read / Write
  "invisible-set"            gboolean              : Read / Write
  "justification"            GtkJustification      : Read / Write

...................例子

	 GdkRGBA  rgba;
	 rgba.red=(gdouble)0xFF/(gdouble)255;/*FF69B4*/
	 rgba.green=(gdouble)0x14/(gdouble)255;/*DeepPink FF93*/
	 rgba.blue=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值