| 1 |
/* vim: set encoding=utf8: |
| 2 |
* |
| 3 |
* shiki.h |
| 4 |
* |
| 5 |
* This file is part of Shiki. |
| 6 |
* |
| 7 |
* Copyright(C)2006 WAKATSUKI toshihiro |
| 8 |
* |
| 9 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 10 |
* copy of this software and associated documentation files (the "Software"), |
| 11 |
* to deal in the Software without restriction, including without limitation |
| 12 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 13 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 14 |
* Software is furnished to do so, subject to the following conditions: |
| 15 |
* |
| 16 |
* The above copyright notice and this permission notice shall be included in |
| 17 |
* all copies or substantial portions of the Software. |
| 18 |
* |
| 19 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 |
* SOFTWARE. |
| 26 |
* |
| 27 |
* $Id: shiki.h,v 1.17 2007/02/03 09:48:01 aloha Exp $ |
| 28 |
*/ |
| 29 |
|
| 30 |
#ifndef SHIKI_H |
| 31 |
#define SHIKI_H |
| 32 |
|
| 33 |
#include<gauche.h> // require >= 0.8.8 |
| 34 |
#include<gtk/gtk.h> |
| 35 |
#include<gdk/gdkkeysyms.h> |
| 36 |
|
| 37 |
/* ��������������������������������������������� */ |
| 38 |
typedef struct { |
| 39 |
const gchar *locale; /* ��������������������������������� */ |
| 40 |
GtkScrolledWindow *tabpage; /* ������ */ |
| 41 |
gchar *tabpage_label; /* ��������������������� */ |
| 42 |
gchar *name; /* ��������� (���������������) ������ */ |
| 43 |
GtkTextView *text_view; /* ��������������� */ |
| 44 |
GtkTextBuffer *text_buffer; /* ��������������������������������� */ |
| 45 |
gchar *filename; /* ������������������������������ */ |
| 46 |
GList *undoInfoList; /* ��������������������������������������� */ |
| 47 |
ScmObj env; /* ��������������������������� Scheme ������ */ |
| 48 |
guint delete_handler_id; /* ��������������������������������������������� ID */ |
| 49 |
} ShikiBuffer; |
| 50 |
|
| 51 |
typedef struct { |
| 52 |
GHashTable *bufname_hash; |
| 53 |
const gchar *default_locale; |
| 54 |
GtkWidget *editor_window; |
| 55 |
GtkClipboard *clipboard; |
| 56 |
GtkNotebook *notebook; |
| 57 |
GtkWidget *statusbar; |
| 58 |
GtkWidget *modeline_label; |
| 59 |
GList *bufferList; |
| 60 |
gint current_tabpage_num; |
| 61 |
ShikiBuffer *current_tabpage_info; |
| 62 |
} ShikiEditorType; |
| 63 |
|
| 64 |
extern ShikiEditorType Shiki_editor; |
| 65 |
|
| 66 |
/* ��������������������������������������������� */ |
| 67 |
#define Shiki_EDITOR_BUFNAME_HASH Shiki_editor.bufname_hash |
| 68 |
#define Shiki_EDITOR_DEFAULT_LOCALE Shiki_editor.default_locale |
| 69 |
#define Shiki_EDITOR_WINDOW Shiki_editor.editor_window |
| 70 |
#define Shiki_EDITOR_CLIPBOARD Shiki_editor.clipboard |
| 71 |
#define Shiki_EDITOR_NOTEBOOK Shiki_editor.notebook |
| 72 |
#define Shiki_EDITOR_STATUSBAR Shiki_editor.statusbar |
| 73 |
#define Shiki_EDITOR_MODELINE_LABEL Shiki_editor.modeline_label |
| 74 |
#define Shiki_EDITOR_BUFFER_LIST Shiki_editor.bufferList |
| 75 |
|
| 76 |
/* ��������������������������������������������������������������������������������������� */ |
| 77 |
#define Shiki_CURRENT_TAB_NUM Shiki_editor.current_tabpage_num |
| 78 |
#define Shiki_CURRENT_TAB_INFO Shiki_editor.current_tabpage_info |
| 79 |
#define Shiki_CURRENT_CES (Shiki_editor.current_tabpage_info)->locale |
| 80 |
#define Shiki_CURRENT_UNDO_INFO_LIST (Shiki_editor.current_tabpage_info)->undoInfoList |
| 81 |
#define Shiki_CURRENT_TAB (Shiki_editor.current_tabpage_info)->tabpage |
| 82 |
#define Shiki_CURRENT_TAB_TITLE (Shiki_editor.current_tabpage_info)->tabpage_label |
| 83 |
#define Shiki_CURRENT_TEXT_VIEW (Shiki_editor.current_tabpage_info)->text_view |
| 84 |
#define Shiki_CURRENT_TEXT_BUFFER (Shiki_editor.current_tabpage_info)->text_buffer |
| 85 |
#define Shiki_CURRENT_BASENAME (Shiki_editor.current_tabpage_info)->name |
| 86 |
#define Shiki_CURRENT_FILENAME (Shiki_editor.current_tabpage_info)->filename |
| 87 |
#define Shiki_CURRENT_BUFFER_ENV (Shiki_editor.current_tabpage_info)->env |
| 88 |
|
| 89 |
/* Undo/Redo ������������������ */ |
| 90 |
typedef enum { |
| 91 |
SHIKI_UNDO_INSERT, |
| 92 |
SHIKI_UNDO_UNDO, |
| 93 |
SHIKI_UNDO_DELETE, |
| 94 |
SHIKI_UNDO_REDO |
| 95 |
} ShikiAction; |
| 96 |
|
| 97 |
typedef struct { |
| 98 |
ShikiAction action; |
| 99 |
gchar *str; |
| 100 |
gint strlen; |
| 101 |
gint start; |
| 102 |
gint end; |
| 103 |
} ShikiUndoInfo; |
| 104 |
|
| 105 |
extern ScmClass *ShikiBufferClass; |
| 106 |
void Scm_Init_xyzzylisp(ScmModule *module); |
| 107 |
|
| 108 |
#define SHIKI_BUFFER_P(obj) SCM_XTYPEP(obj, ShikiBufferClass) |
| 109 |
#define SHIKI_BUFFER_UNBOX(obj) SCM_FOREIGN_POINTER_REF(GtkTextBuffer*, obj) |
| 110 |
#define SHIKI_BUFFER_BOX(ptr) Scm_MakeForeignPointer(ShikiBufferClass, ptr) |
| 111 |
|
| 112 |
/* C API */ |
| 113 |
GtkTextBuffer *Shiki_new_buffer_create(gchar *filename); |
| 114 |
gchar *Shiki_buffer_substring(gint start, gint end); |
| 115 |
void Shiki_delete_region(gint start, gint end); |
| 116 |
gint Shiki_point(); |
| 117 |
gint Shiki_point_max(); |
| 118 |
gint Shiki_point_min(); |
| 119 |
void Shiki_goto_char(gint offset); |
| 120 |
void Shiki_forward_char(); |
| 121 |
void Shiki_backward_char(); |
| 122 |
void Shiki_goto_line(gint line); |
| 123 |
void Shiki_goto_bol(); |
| 124 |
void Shiki_goto_eol(); |
| 125 |
void Shiki_forward_line(gint count); |
| 126 |
const gchar *Shiki_buffer_name(GtkTextBuffer *buffer); |
| 127 |
GtkTextBuffer *Shiki_get_next_buffer(GtkTextBuffer *buffer); |
| 128 |
GtkTextBuffer *Shiki_get_previous_buffer(GtkTextBuffer *buffer); |
| 129 |
ScmObj Shiki_buffer_list(); |
| 130 |
gboolean Shiki_deleted_buffer_p(GtkTextBuffer *buffer); |
| 131 |
void Shiki_erase_buffer(GtkTextBuffer *buffer); |
| 132 |
void Shiki_delete_buffer(GtkTextBuffer *buffer); |
| 133 |
GtkTextBuffer *Shiki_find_buffer(const gchar *name); |
| 134 |
const gchar *Shiki_file_name_dialog(const gchar *msg); |
| 135 |
gboolean Shiki_yes_or_no_p(const gchar *msg); |
| 136 |
gboolean Shiki_no_or_yes_p(const gchar *msg); |
| 137 |
gboolean Shiki_need_buffer_save_p(GtkTextBuffer *buffer); |
| 138 |
void Shiki_kill_buffer(GtkTextBuffer *buffer); |
| 139 |
void Shiki_create_file_buffer(const gchar *filename); |
| 140 |
void Shiki_open_file_dialog(); |
| 141 |
void Shiki_update_modeline(); |
| 142 |
void Shiki_undo(); |
| 143 |
void Shiki_redo(); |
| 144 |
void Shiki_msgbox(const gchar *msg); |
| 145 |
void Shiki_eval_expression(); |
| 146 |
void Shiki_eval_last_sexp(); |
| 147 |
|
| 148 |
void Shiki_search_buffer(); |
| 149 |
void Shiki_replace_buffer(); |
| 150 |
|
| 151 |
void Shiki_load_file(const gchar *filename); |
| 152 |
#endif |