| 39 |
static GtkTextBuffer *current_text_buffer; |
static GtkTextBuffer *current_text_buffer; |
| 40 |
|
|
| 41 |
static GtkWidget *statusbar; |
static GtkWidget *statusbar; |
| 42 |
|
static GtkWidget *modeline_label; |
| 43 |
|
|
| 44 |
|
/* 現在のバッファのカーソル位置の行番号を取得 */ |
| 45 |
|
static gint get_current_line_number(GtkTextBuffer *b) { |
| 46 |
|
GtkTextIter p; |
| 47 |
|
gtk_text_buffer_get_iter_at_mark(b, &p, gtk_text_buffer_get_insert(b)); |
| 48 |
|
return gtk_text_iter_get_line(&p) + 1; |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
/* バッファの状態に合わせてモードラインを変更 */ |
| 52 |
|
static void update_modeline_label() { |
| 53 |
|
gchar* basename = g_path_get_basename(current_tabpage_label); |
| 54 |
|
gchar* l = g_strdup_printf("-E:%s %-10s (Lisp Interaction)--L%d--------------------------------------", |
| 55 |
|
gtk_text_buffer_get_modified(current_text_buffer) ? "**" : "--", |
| 56 |
|
basename, get_current_line_number(current_text_buffer)); |
| 57 |
|
gtk_label_set_text(GTK_LABEL(modeline_label), l); |
| 58 |
|
g_free(l); g_free(basename); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
static void text_buffer_cursor_moved_handler(){ |
| 62 |
|
update_modeline_label(); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
/* テキストバッファから全ての文字列を取り出す */ |
/* テキストバッファから全ての文字列を取り出す */ |
| 66 |
static gchar* get_all_buffer_contents(GtkTextBuffer *buffer) { |
static gchar* get_all_buffer_contents(GtkTextBuffer *buffer) { |
| 82 |
/* 文字列をファイルに保存 */ |
/* 文字列をファイルに保存 */ |
| 83 |
g_file_set_contents(filename, text, -1, NULL); |
g_file_set_contents(filename, text, -1, NULL); |
| 84 |
gtk_text_buffer_set_modified(buffer, FALSE); |
gtk_text_buffer_set_modified(buffer, FALSE); |
| 85 |
|
update_modeline_label(); |
| 86 |
g_free(contents); g_free(text); |
g_free(contents); g_free(text); |
| 87 |
return TRUE; |
return TRUE; |
| 88 |
} |
} |
| 211 |
gtk_container_add(GTK_CONTAINER(scrolledwindow), view); |
gtk_container_add(GTK_CONTAINER(scrolledwindow), view); |
| 212 |
g_signal_connect(G_OBJECT(editor_window), "delete_event", G_CALLBACK(delete_event_handler), buffer); |
g_signal_connect(G_OBJECT(editor_window), "delete_event", G_CALLBACK(delete_event_handler), buffer); |
| 213 |
gtk_widget_set_size_request(GTK_WIDGET(view), 500, 500); |
gtk_widget_set_size_request(GTK_WIDGET(view), 500, 500); |
| 214 |
|
g_signal_connect(buffer, "mark_set", G_CALLBACK(text_buffer_cursor_moved_handler), view); |
| 215 |
/* 様々な初期化処理 */ |
/* 様々な初期化処理 */ |
| 216 |
/* 括弧の強調表示のためのタグを作る */ |
/* 括弧の強調表示のためのタグを作る */ |
| 217 |
gtk_text_buffer_create_tag (buffer, "parent_emphasis_background", "background", "green", NULL); |
gtk_text_buffer_create_tag (buffer, "parent_emphasis_background", "background", "green", NULL); |
| 249 |
/* カーソル位置を先頭に */ |
/* カーソル位置を先頭に */ |
| 250 |
gtk_text_buffer_get_start_iter(buffer, &p); |
gtk_text_buffer_get_start_iter(buffer, &p); |
| 251 |
gtk_text_buffer_place_cursor(buffer, &p); |
gtk_text_buffer_place_cursor(buffer, &p); |
| 252 |
|
update_modeline_label(); |
| 253 |
gtk_window_set_title (GTK_WINDOW (editor_window), filename); |
gtk_window_set_title (GTK_WINDOW (editor_window), filename); |
| 254 |
gtk_widget_show_all(GTK_WIDGET(notebook)); |
gtk_widget_show_all(GTK_WIDGET(notebook)); |
| 255 |
g_free(contents); g_free(text); g_free(filename); |
g_free(contents); g_free(text); g_free(filename); |
| 369 |
|
|
| 370 |
/* タブのラベルをウィンドウのタイトルに */ |
/* タブのラベルをウィンドウのタイトルに */ |
| 371 |
gtk_window_set_title (GTK_WINDOW(editor_window), current_tabpage_label = gtk_notebook_get_tab_label_text(notebook, GTK_WIDGET(current_tabpage))); |
gtk_window_set_title (GTK_WINDOW(editor_window), current_tabpage_label = gtk_notebook_get_tab_label_text(notebook, GTK_WIDGET(current_tabpage))); |
| 372 |
|
|
| 373 |
|
update_modeline_label(); |
| 374 |
} |
} |
| 375 |
|
|
| 376 |
/* ページのタブと境界線を on/off */ |
/* ページのタブと境界線を on/off */ |
| 641 |
gtk_container_add(GTK_CONTAINER(editor_window), vbox); |
gtk_container_add(GTK_CONTAINER(editor_window), vbox); |
| 642 |
gtk_container_add(GTK_CONTAINER(vbox), notebook); |
gtk_container_add(GTK_CONTAINER(vbox), notebook); |
| 643 |
|
|
|
/* デフォルトのページを追加 */ |
|
|
gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), |
|
|
new_scrolled_text_buffer(), |
|
|
gtk_label_new("*scratch*")); |
|
|
|
|
| 644 |
icon = gtk_tool_button_new(gtk_image_new_from_stock ("gtk-apply", iconsize), "append"); |
icon = gtk_tool_button_new(gtk_image_new_from_stock ("gtk-apply", iconsize), "append"); |
| 645 |
g_signal_connect(G_OBJECT(icon), "clicked", G_CALLBACK(tabsborder_on_off), G_OBJECT(notebook)); |
g_signal_connect(G_OBJECT(icon), "clicked", G_CALLBACK(tabsborder_on_off), G_OBJECT(notebook)); |
| 646 |
gtk_container_add(GTK_CONTAINER (toolbar), GTK_WIDGET(icon)); |
gtk_container_add(GTK_CONTAINER (toolbar), GTK_WIDGET(icon)); |
| 662 |
gtk_tool_item_set_tooltip(icon, toolbar_tips, "バッファを閉じます", |
gtk_tool_item_set_tooltip(icon, toolbar_tips, "バッファを閉じます", |
| 663 |
"まだ内容が保存されていない場合は警告します"); |
"まだ内容が保存されていない場合は警告します"); |
| 664 |
|
|
| 665 |
gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new("-E:** *scratch* (Lisp Interaction)--L1--All---------------------------------"), TRUE, TRUE, 0); |
gtk_box_pack_start(GTK_BOX(vbox), modeline_label = gtk_label_new("-E:** *scratch* (Lisp Interaction)--L1--All---------------------------------"), TRUE, TRUE, 0); |
| 666 |
|
|
| 667 |
/* C-x C-s などの状態を表示するステータスバーをウィンドウボトムに追加 */ |
/* C-x C-s などの状態を表示するステータスバーをウィンドウボトムに追加 */ |
| 668 |
statusbar = gtk_statusbar_new(); |
statusbar = gtk_statusbar_new(); |
| 672 |
/* キーバインドのハンドリングを登録 */ |
/* キーバインドのハンドリングを登録 */ |
| 673 |
g_signal_connect(G_OBJECT(notebook), "key-press-event", G_CALLBACK (signal_key_press_handler), GINT_TO_POINTER(contextid)); |
g_signal_connect(G_OBJECT(notebook), "key-press-event", G_CALLBACK (signal_key_press_handler), GINT_TO_POINTER(contextid)); |
| 674 |
g_signal_connect(G_OBJECT(notebook), "key-release-event", G_CALLBACK (signal_key_release_handler), GINT_TO_POINTER(contextid)); |
g_signal_connect(G_OBJECT(notebook), "key-release-event", G_CALLBACK (signal_key_release_handler), GINT_TO_POINTER(contextid)); |
| 675 |
|
|
| 676 |
|
/* デフォルトのページを追加 */ |
| 677 |
|
gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), new_scrolled_text_buffer(), gtk_label_new("*scratch*")); |
| 678 |
|
|
| 679 |
gtk_widget_grab_focus(notebook); |
gtk_widget_grab_focus(notebook); |
| 680 |
gtk_widget_show_all(editor_window); |
gtk_widget_show_all(editor_window); |