- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想在 GtkSourceView 中用红色标记一些文本并显示一个图标。在这里,我目前的尝试似乎什么也没做:
void plainTextEditor_textView_addLineMarker(int lineNumber, linemarker* marker, context_base* context)
{
GtkWidget* plainTextEditor_textView = get_plainTextEditor_textView_from_notebook(context->notebook);
GtkTextIter iter;
GtkTextBuffer * buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(plainTextEditor_textView) );
gtk_text_buffer_get_iter_at_line( buffer, &iter, lineNumber );
printf("extendedEditor_linebox_markError %i\n", lineNumber);
gtk_source_buffer_create_source_mark( GTK_SOURCE_BUFFER(buffer), marker->message, "dialog-error", &iter );
}
printf 打印出正确的行号。
如果我调用该方法两次,gtk 会打印一些 gtk-critical:“Mark myMark already exists in the buffer”。
但是在 gtksourceview 上根本没有可见的变化。
也许我应该用 gtk_source_mark_attributes
来改变特定类别的属性?但是怎么办?我找不到任何关于如何使用它的好信息。
最佳答案
好吧,我自己想通了。这里的版本将背景标记为红色并显示一个小的错误对话框项目。如果鼠标悬停在项目上,将显示一条错误消息。
//data which is needed in different methods
typedef struct
{
GtkSourceMarkAttributes* plainTextEditor_lineMarkers_warningAttributes;
GtkSourceMarkAttributes* plainTextEditor_lineMarkers_errorAttributes;
...
} context_base;
// things to do only once
int main(int argc, char *argv[])
{
...
GtkWidget * plainTextEditor_textView = gtk_source_view_new();
gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW(plainTextEditor_textView),TRUE);
gtk_source_view_set_show_line_numbers (GTK_SOURCE_VIEW(plainTextEditor_textView),TRUE);
gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW(plainTextEditor_textView), TRUE);
context->plainTextEditor_lineMarkers_errorAttributes = gtk_source_mark_attributes_new();
gtk_source_mark_attributes_set_background(context->plainTextEditor_lineMarkers_errorAttributes, &error_color);
gtk_source_mark_attributes_set_icon_name(context->plainTextEditor_lineMarkers_errorAttributes,"dialog-error");
gtk_source_view_set_mark_attributes( GTK_SOURCE_VIEW(plainTextEditor_textView), sourceMarkCategory_error, context->plainTextEditor_lineMarkers_errorAttributes, 10);
...
}
// callback to display message when hovering on the linemarker
gchar* on_lineMarkerTooltip_displayed(GtkSourceMarkAttributes *attributes, GtkSourceMark *mark, linemarker* marker)
{
if( marker->message == NULL)
return NULL;
return strdup(marker->message);
}
// method to create new linemark
void plainTextEditor_textView_addLineMarker(int lineNumber, linemarker* marker, context_base* context)
{
if( context->plainTextEditor_lineMarkers[lineNumber-1]->message != NULL ) // there is a message on this line
{
if( strcmp(context->plainTextEditor_lineMarkers[lineNumber-1]->message, marker->message ) == 0 ) // its the same message, nothing to do
{
return;
}
}
GtkWidget* plainTextEditor_textView = get_plainTextEditor_textView_from_notebook(context->notebook);
GtkTextIter iter;
GtkTextBuffer * buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(plainTextEditor_textView) );
gtk_text_buffer_get_iter_at_line( buffer, &iter, lineNumber );
context->plainTextEditor_lineMarkers[lineNumber-1]->message = strdup(marker->message);
char sourceMarkName[sourceMarkNameMaxDigits];
snprintf(sourceMarkName, sourceMarkNameMaxDigits, "%i", lineNumber);
gtk_source_view_set_mark_attributes (GTK_SOURCE_VIEW(plainTextEditor_textView),sourceMarkCategory_error,context->plainTextEditor_lineMarkers_errorAttributes,10);
gtk_source_buffer_create_source_mark( GTK_SOURCE_BUFFER(buffer), sourceMarkName, sourceMarkCategory_error, &iter );
g_signal_connect(G_OBJECT(context->plainTextEditor_lineMarkers_errorAttributes), "query-tooltip-text", G_CALLBACK(on_lineMarkerTooltip_displayed), context->plainTextEditor_lineMarkers[lineNumber-1]);
}
关于c - GtkSourceView/GtkSourceBuffer - 如何用红色标记一行并显示一个图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42403102/
我想要以下代码的 Python 单行解决方案,但是怎么做呢? total = 0 for ob in self.oblist: total += sum(v.amount for v in o
今天和大家一起学习一种可视化技术:构建树状热力图treemap。树形图易于可视化,且易于被人理解。树状图通过展示不同大小的矩形,以传达不同大小的数据量,一般认为,较大的矩形意味着占总体的一大部分,而较
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我有一个声明 $set eq "Y" ? $set = "N" : $set = "Y"; 但不管它总是设置为 "N" # Toggle setting if ($set eq "Y") { $
当我尝试在我的服务器上上传一个 php 文件时,我收到一条消息:"Parse error: ..." 我知道这是什么意思,但问题是别的。 如果我在本地服务器上编辑文件(我的计算机上安装了 XAMPP)
我是 python oneliner 循环的新手。 我希望用户将数据输入到二维列表中,同时提醒他他们将输入的数据索引。我的代码是: flag=0 x=[[int(input("enter the "+
尝试在变量之前和之后打印字符串。C 是否有能力使用一条语句来显示此输出? 这有效: float value = 5; printf("\nThe value of %f", value); print
我正在验证我创建的 MySQL 数据库的结果,为此,我需要一些屏幕截图。 例如,以下查询: select distinct run_ID from ngsRunStats_FK.failedRuns
有人可以解释一下这个 JS LINE 吗?数据是一个对象。 var list = data == null ? [] : (data.wine instanceof Array ? data.wine
如何在一行中添加三个下拉菜单。我想把我的日、月和年放在一行中,但不能这样做。任何帮助将不胜感激。我附上我的 jsfiddle . .... 最佳
我正在尝试使用 html 将 iframe 的高度设置为 100%(我已成功完成),但我还在顶部添加了一行额外的文本,所以它太高了 ~16px(这需要一个滚动条)。有没有办法更改 iframe 以显示
这是一个示例,我从文件中读取行作为字符串,以使整个文件作为字符串数组: String[] ArrayOfStrings = (new Scanner( new File("log.txt") ).us
我有一个包含大量定义的配置文件,用于在编译期间包含模块。此外,这意味着我必须经常检查代码内部的定义。每张支票需要 3 行,是否可以在一行中执行此操作。 #if FUNC_ENABLED functio
我正在尝试制作一个水平列表,其中每个 列表中的 s 的高度为 385px,宽度为 400px。 我尝试使用 inline-block 使列表水平排列,但这似乎不起作用。也就是说,我的意思是列表仍然是垂
这很烦人,我有一个带有 css 文件的 wordpress 主题,所有内容都在一长行中。我想知道为什么有人会那样做。现在我已经升级了,我需要将旧文件与新文件进行比较,以便我可以接受更改。 Meld、d
我有一个对象数组,其中每个对象都有一个 search_order 属性。我要检查数组并将所有对象的属性增加 1这是简单的方法: res = [] for r in array: r.searc
我在某些服务器上遇到许多具有相同内容和相同名称的文件。我需要隔离这些文件进行分析,所以我不能只删除重复项。操作系统为Linux(centos和ubuntu)。 我枚举文件名和位置并将它们放入文本文件中
你能在不抛出错误的情况下解决这个问题吗?答案是单线。这是来自一个死的职位发布,在回复中要求回答。我认为这是剔除受访者的聪明方法,但我似乎无法在不出错的情况下回答它。 显而易见的解决方案: f.moo(
这个问题在这里已经有了答案: Is it ok if I omit curly braces in Java? [closed] (16 个答案) 关闭 9 年前。 我在 java 中使用没有大括号
我在这里试图用 python 制作一个简单的计算器,我想知道是否可以在命令运行时将前 3 行合并为一行。我的意思是;我不必按 Enter 键来键入下一个数字/运算符,而是按空格键(在输入部分)。 wh
我是一名优秀的程序员,十分优秀!