我想用gtk和glad制作一个在gtktextview中打印的应用程序,gtkbuffer中有什么。我该怎么做 ?
我尝试了很多事情,但是gtk的gtktextview却不知道林间空地的gtktextview。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
GtkWidget *text_view;
//GtkTextView *text_view;
GtkBuilder *builder;
//GtkTextBuffer *text_buffer;
GtkWidget *text_buffer;
void recieved_text (gchar *m) {
// GtkTextIter e;
// printf("yo msg :%s ",m);
(void)m;
GtkTextIter start,end;
GtkTextView *vu= GTK_TEXT_VIEW(text_view);
GtkTextBuffer *buffer = gtk_text_view_get_buffer (vu);
char *text;
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
printf("text in textview: %s\n",text);
gtk_text_buffer_insert(buffer, &end, m, -1);
gtk_text_buffer_insert(buffer, &end, "\n", -1);
char * text2;
gtk_text_buffer_get_bounds (buffer, &start, &end);
text2 = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
printf("text2 in textview: %s\n",text2);
}