1 /* 2 3 Copyright (c) 2003-2013 uim Project https://github.com/uim/uim 4 5 All rights reserved. 6 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions 9 are met: 10 11 1. Redistributions of source code must retain the above copyright 12 notice, this list of conditions and the following disclaimer. 13 2. Redistributions in binary form must reproduce the above copyright 14 notice, this list of conditions and the following disclaimer in the 15 documentation and/or other materials provided with the distribution. 16 3. Neither the name of authors nor the names of its contributors 17 may be used to endorse or promote products derived from this software 18 without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 24 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 SUCH DAMAGE. 31 32 */ 33 34 #ifndef UIM_FEP_H 35 #define UIM_FEP_H 36 37 #ifdef HAVE_CONFIG_H 38 #include <config.h> 39 #endif 40 #ifdef HAVE_SYS_IOCTL_H 41 #include <sys/ioctl.h> 42 #endif 43 /* solaris でwinsizeを使うために必要 */ 44 #ifdef HAVE_CURSES_H 45 #include <curses.h> 46 #endif 47 #if defined(__CYGWIN32__) || defined(__sun) 48 #ifdef HAVE_SYS_TERMIOS_H 49 #include <sys/termios.h> 50 #endif 51 #endif 52 #include <uim/uim.h> 53 54 #define FALSE 0 55 #define TRUE 1 56 #define NONE 2 57 #define LASTLINE 3 58 #define BACKTICK 4 59 #define UNDEFINED -1729 60 #define ESCAPE_CODE 27 61 #define WIN_OUT_FILENO STDOUT_FILENO 62 #define WIN_IN_FILENO STDOUT_FILENO 63 #define PROC_FILENO STDIN_FILENO 64 65 struct opt_tag { 66 /* ステータスラインの種類 */ 67 int status_type; 68 /* ddskkに似た候補の表示 */ 69 int ddskk; 70 /* TRUEならカーソル位置を反転しない */ 71 int cursor_no_reverse; 72 /* カーソルを消すか */ 73 int use_civis; 74 /* プリエディットを挿入するか */ 75 int on_the_spot; 76 /* ステータスラインの幅 */ 77 int statusline_width; 78 /* ESCの後に何秒待つか */ 79 int timeout; 80 /* レポートカーソル機能がないか */ 81 int no_report_cursor; 82 int print_key; 83 }; 84 85 extern struct opt_tag g_opt; 86 extern int g_win_in; 87 extern int g_win_out; 88 extern struct winsize *g_win; 89 extern uim_context g_context; 90 91 void done(int exit_value); 92 93 #ifdef DEBUG 94 95 #if DEBUG > 2 96 #define debug2(arg) _debug arg 97 #define debug(arg) _debug arg 98 #define debug_write2(str, len) _debug_write(str, len) 99 #define debug_write(str, len) _debug_write(str, len) 100 void _debug(const char *fmt, ...); 101 void _debug_write(const char *str, int len); 102 103 #elif DEBUG == 2 104 #define debug2(arg) 105 #define debug(arg) _debug arg 106 #define debug_write2(str, len) 107 #define debug_write(str, len) _debug_write(str, len) 108 109 void _debug(const char *fmt, ...); 110 void _debug_write(const char *str, int len); 111 #else 112 #define debug2(arg) 113 #define debug(arg) 114 #define debug_write2(str, len) 115 #define debug_write(str, len) 116 #endif 117 118 #define return_if_fail(arg) if (!(arg)) { printf("assertion failed %s %d", __FILE__, __LINE__); return; } 119 120 #else 121 #define debug2(arg) 122 #define debug(arg) 123 #define debug_write2(str, len) 124 #define debug_write(str, len) 125 #define return_if_fail(arg) if (!(arg)) { return; } 126 #endif 127 128 #endif 129