1 /* 2 * Copyright 2018 Jiri Techet <techet@gmail.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __VIMODE_VI_H__ 20 #define __VIMODE_VI_H__ 21 22 #include "sci.h" 23 24 #define VI_IS_VISUAL(m) ((m) == VI_MODE_VISUAL || (m) == VI_MODE_VISUAL_LINE || (m) == VI_MODE_VISUAL_BLOCK) 25 #define VI_IS_COMMAND(m) ((m) == VI_MODE_COMMAND || (m) == VI_MODE_COMMAND_SINGLE) 26 #define VI_IS_INSERT(m) ((m) == VI_MODE_INSERT || (m) == VI_MODE_REPLACE) 27 28 typedef enum { 29 VI_MODE_COMMAND, 30 VI_MODE_COMMAND_SINGLE, //performing single command from insert mode using Ctrl+O 31 VI_MODE_VISUAL, 32 VI_MODE_VISUAL_LINE, 33 VI_MODE_VISUAL_BLOCK, //not implemented 34 VI_MODE_INSERT, 35 VI_MODE_REPLACE, 36 } ViMode; 37 38 typedef struct 39 { 40 void (*on_mode_change)(ViMode mode); 41 gboolean (*on_save)(gboolean force); 42 gboolean (*on_save_all)(gboolean force); 43 void (*on_quit)(gboolean force); 44 } ViCallback; 45 46 47 void vi_enter_ex_mode(void); 48 void vi_set_mode(ViMode mode); 49 ViMode vi_get_mode(void); 50 51 gboolean vi_notify_sci(SCNotification *nt); 52 gboolean vi_notify_key_press(GdkEventKey *event); 53 54 void vi_init(GtkWidget *parent_window, ViCallback *cb); 55 void vi_cleanup(void); 56 57 void vi_set_active_sci(ScintillaObject *sci); 58 59 void vi_set_enabled(gboolean enabled); 60 void vi_set_insert_for_dummies(gboolean enabled); 61 gboolean vi_get_enabled(void); 62 gboolean vi_get_insert_for_dummies(void); 63 64 #endif 65