Develop and Download Open Source Software

Browse CVS Repository

Diff of /shiki/shiki/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.14 by aloha, Sun Dec 3 15:21:04 2006 UTC revision 1.15 by aloha, Thu Dec 28 05:04:45 2006 UTC
# Line 28  Line 28 
28   */   */
29  #include"shiki.h"  #include"shiki.h"
30    
 ScmClass *ShikiBufferClass;  
 extern void Scm_Init_xyzzylisp(ScmModule *module);  
   
31  /* GtkTextBuffer から,対応する ShikiBuffer 構造体を逆引き */  /* GtkTextBuffer から,対応する ShikiBuffer 構造体を逆引き */
32  static gint compBuffer(gconstpointer a, gconstpointer b) {  static gint compBuffer(gconstpointer a, gconstpointer b) {
33    return ((ShikiBuffer *)a)->text_buffer == b ? 0 : b - a;    return ((ShikiBuffer *)a)->text_buffer == b ? 0 : b - a;
# Line 40  static GList *get_ShikiBufferListElement Line 37  static GList *get_ShikiBufferListElement
37    return g_list_find_custom(Shiki_EDITOR_BUFFER_LIST, b, compBuffer);    return g_list_find_custom(Shiki_EDITOR_BUFFER_LIST, b, compBuffer);
38  }  }
39    
 static void buffer_print(ScmObj obj, ScmPort *out, ScmWriteContext *ctx) {  
   GtkTextBuffer *b = SHIKI_BUFFER_UNBOX(obj);  
   GList *l  = g_list_find_custom(Shiki_EDITOR_BUFFER_LIST, b, compBuffer);  
     if(l)  
       Scm_Printf(out, "#<buffer: %s>", ((ShikiBuffer *)(l->data))->name);  
     else  
       Scm_Printf(out, "#<deleted buffer: %p>", b);  
 }  
   
 static void buffer_cleanup(ScmObj obj)  
 {  
   g_object_unref(SHIKI_BUFFER_UNBOX(obj));  
 }  
   
40  /* バッファがまだ保存されていないのに本当に終了するのかを尋ねる */  /* バッファがまだ保存されていないのに本当に終了するのかを尋ねる */
41  static gboolean delete_event_handler(GtkWidget *widget, GdkEvent *event, GtkTextBuffer *buffer){  static gboolean delete_event_handler(GtkWidget *widget, GdkEvent *event, GtkTextBuffer *buffer){
42    /* delete-event が発行された際,FALSE を返したらバッファは破棄される */    /* delete-event が発行された際,FALSE を返したらバッファは破棄される */
# Line 246  void Shiki_redo() { Line 229  void Shiki_redo() {
229  }  }
230    
231  /* バッファの状態に合わせてモードラインを変更 */  /* バッファの状態に合わせてモードラインを変更 */
232  void Shiki_update_modeline(GtkTextBuffer *buffer) {  void Shiki_update_modeline() {
233    gtk_label_set_text(GTK_LABEL(Shiki_EDITOR_MODELINE_LABEL), Scm_GetString(SCM_STRING(Scm_EvalCString("(if *mode-line-format* (*mode-line-format*) \"\")", Shiki_CURRENT_BUFFER_ENV))));    gtk_label_set_text(GTK_LABEL(Shiki_EDITOR_MODELINE_LABEL), Scm_GetString(SCM_STRING(Scm_EvalCString("(if *mode-line-format* (*mode-line-format*) \"\")", Shiki_CURRENT_BUFFER_ENV))));
234  }  }
235    
236  static void cursor_moved_handler() {  static void cursor_moved_handler() {
237    Shiki_update_modeline(Shiki_CURRENT_TEXT_BUFFER);    Shiki_update_modeline();
238  }  }
239    
240  /* ノートブックにタブとページ (バッファ) を追加 */  /* ノートブックにタブとページ (バッファ) を追加 */
# Line 266  GtkTextBuffer *Shiki_new_buffer_create(g Line 249  GtkTextBuffer *Shiki_new_buffer_create(g
249    tabinfo->tabpage_label = g_strndup(tabinfo->name, 10);    tabinfo->tabpage_label = g_strndup(tabinfo->name, 10);
250    tabinfo->env           = Scm_MakeModule(NULL, FALSE);    tabinfo->env           = Scm_MakeModule(NULL, FALSE);
251    
   ShikiBufferClass = Scm_MakeForeignPointerClass(SCM_MODULE(tabinfo->env),  
       "<buffer>", buffer_print, buffer_cleanup,  
       SCM_FOREIGN_POINTER_KEEP_IDENTITY  
       |  
       SCM_FOREIGN_POINTER_MAP_NULL);  
   
252    /* xyzzy lisp 関数を登録 */    /* xyzzy lisp 関数を登録 */
253    Scm_Init_xyzzylisp(SCM_MODULE(tabinfo->env));    Scm_Init_xyzzylisp(SCM_MODULE(tabinfo->env));
254    
# Line 725  static gchar *eval_cstring_by_gauche(gch Line 702  static gchar *eval_cstring_by_gauche(gch
702    
703    return msg;    return msg;
704  }  }
705    void Shiki_load_file(const gchar *filename) {
706      gchar *result, *utf8filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
707      GtkTextIter p;
708    
709      Scm_Define(SCM_MODULE(Shiki_CURRENT_BUFFER_ENV), SCM_SYMBOL(SCM_INTERN("*filename*")), SCM_MAKE_STR_COPYING(utf8filename));
710      result = eval_cstring_by_gauche("(load *filename*)");
711    
712      gtk_text_buffer_get_end_iter(Shiki_CURRENT_TEXT_BUFFER, &p);
713      gtk_text_buffer_insert(Shiki_CURRENT_TEXT_BUFFER, &p, "\n", -1);
714      gtk_text_buffer_insert(Shiki_CURRENT_TEXT_BUFFER, &p, result, -1);
715    }
716    
717  void Shiki_eval_expression() {  void Shiki_eval_expression() {
718    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26