root/src/textconv.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


     1 /* String conversion support for graphics terminals.
     2 
     3 Copyright (C) 2023 Free Software Foundation, Inc.
     4 
     5 This file is part of GNU Emacs.
     6 
     7 GNU Emacs is free software: you can redistribute it and/or modify
     8 it under the terms of the GNU General Public License as published by
     9 the Free Software Foundation, either version 3 of the License, or (at
    10 your option) any later version.
    11 
    12 GNU Emacs is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    19 
    20 #ifndef _TEXTCONV_H_
    21 
    22 #include "lisp.h"
    23 #include "frame.h"
    24 
    25 /* The function pointers in this structure should be filled out by
    26    each GUI backend interested in supporting text conversion.
    27 
    28    Finally, register_texconv_interface must be called at some point
    29    during terminal initialization.  */
    30 
    31 struct textconv_interface
    32 {
    33   /* Notice that the text conversion context has changed (which can
    34      happen if the window is deleted or switches buffers, or an
    35      unexpected buffer change occurs.) */
    36   void (*reset) (struct frame *);
    37 
    38   /* Notice that point or mark has moved in the specified frame's
    39      selected window's selected buffer.  The second argument is the
    40      window whose point changed, and the third argument is the
    41      buffer.  */
    42   void (*point_changed) (struct frame *, struct window *,
    43                          struct buffer *);
    44 
    45   /* Notice that the preconversion region has changed without point
    46      being moved.  */
    47   void (*compose_region_changed) (struct frame *);
    48 
    49   /* Notice that an asynch conversion identified by COUNTER has
    50      completed.  */
    51   void (*notify_conversion) (unsigned long);
    52 };
    53 
    54 
    55 
    56 enum textconv_caret_direction
    57   {
    58     TEXTCONV_FORWARD_CHAR,
    59     TEXTCONV_BACKWARD_CHAR,
    60     TEXTCONV_FORWARD_WORD,
    61     TEXTCONV_BACKWARD_WORD,
    62     TEXTCONV_CARET_UP,
    63     TEXTCONV_CARET_DOWN,
    64     TEXTCONV_NEXT_LINE,
    65     TEXTCONV_PREVIOUS_LINE,
    66     TEXTCONV_LINE_START,
    67     TEXTCONV_LINE_END,
    68     TEXTCONV_ABSOLUTE_POSITION,
    69   };
    70 
    71 enum textconv_operation
    72   {
    73     TEXTCONV_SUBSTITUTION,
    74     TEXTCONV_RETRIEVAL,
    75   };
    76 
    77 /* Structure describing text in a buffer corresponding to a ``struct
    78    textconv_callback_struct''.  */
    79 
    80 struct textconv_conversion_text
    81 {
    82   /* Length of the text in characters and bytes.  */
    83   size_t length, bytes;
    84 
    85   /* Pointer to the text data.  This must be deallocated by the
    86      caller.  */
    87   char *text;
    88 };
    89 
    90 /* Structure describing a single query submitted by the input
    91    method.  */
    92 
    93 struct textconv_callback_struct
    94 {
    95   /* Character position, relative to the current spot location, from
    96      where on text should be returned.  */
    97   EMACS_INT position;
    98 
    99   /* The type of scanning to perform to determine either the start or
   100      the end of the conversion.  */
   101   enum textconv_caret_direction direction;
   102 
   103   /* The the number of times for which to repeat the scanning in order
   104      to determine the starting position of the text to return.  */
   105   unsigned short factor;
   106 
   107   /* The operation to perform upon the current buffer contents.
   108 
   109      If this is TEXTCONV_SUBSTITUTION, then the text that is returned
   110      will be deleted from the buffer itself.
   111 
   112      Otherwise, the text is simply returned without modifying the
   113      buffer contents.  */
   114   enum textconv_operation operation;
   115 
   116   /* Structure that will be filled with a description of the resulting
   117      text.  */
   118   struct textconv_conversion_text text;
   119 };
   120 
   121 
   122 
   123 #define TEXTCONV_SKIP_CONVERSION_REGION (1 << 0)
   124 
   125 extern int textconv_query (struct frame *, struct textconv_callback_struct *,
   126                            int);
   127 extern bool detect_conversion_events (void);
   128 extern void handle_pending_conversion_events (void);
   129 extern void start_batch_edit (struct frame *, unsigned long);
   130 extern void end_batch_edit (struct frame *, unsigned long);
   131 extern void commit_text (struct frame *, Lisp_Object, ptrdiff_t,
   132                          unsigned long);
   133 extern void finish_composing_text (struct frame *, unsigned long,
   134                                    bool);
   135 extern void set_composing_text (struct frame *, Lisp_Object,
   136                                 ptrdiff_t, unsigned long);
   137 extern void set_composing_region (struct frame *, ptrdiff_t, ptrdiff_t,
   138                                   unsigned long);
   139 extern void textconv_set_point_and_mark (struct frame *, ptrdiff_t,
   140                                          ptrdiff_t, unsigned long);
   141 extern void delete_surrounding_text (struct frame *, ptrdiff_t,
   142                                      ptrdiff_t, unsigned long);
   143 extern void request_point_update (struct frame *, unsigned long);
   144 extern void textconv_barrier (struct frame *, unsigned long);
   145 extern char *get_extracted_text (struct frame *, ptrdiff_t, ptrdiff_t *,
   146                                  ptrdiff_t *, ptrdiff_t *, ptrdiff_t *,
   147                                  ptrdiff_t *, bool *);
   148 extern char *get_surrounding_text (struct frame *, ptrdiff_t,
   149                                    ptrdiff_t, ptrdiff_t *,
   150                                    ptrdiff_t *, ptrdiff_t *,
   151                                    ptrdiff_t *, ptrdiff_t *);
   152 extern bool conversion_disabled_p (void);
   153 extern void check_postponed_buffers (void);
   154 
   155 extern void register_textconv_interface (struct textconv_interface *);
   156 
   157 #endif /* _TEXTCONV_H_ */

/* [<][>][^][v][top][bottom][index][help] */