1  /* context_stack.h - declarations for context_stack.c */
       2  #ifndef CONTEXT_STACK_H
       3  #define CONTEXT_STACK_H
       4  /* Copyright 2010-2023 Free Software Foundation, Inc.
       5  
       6     This program is free software: you can redistribute it and/or modify
       7     it under the terms of the GNU General Public License as published by
       8     the Free Software Foundation, either version 3 of the License, or
       9     (at your option) any later version.
      10  
      11     This program is distributed in the hope that it will be useful,
      12     but WITHOUT ANY WARRANTY; without even the implied warranty of
      13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14     GNU General Public License for more details.
      15  
      16     You should have received a copy of the GNU General Public License
      17     along with this program.  If not, see <http://www.gnu.org/licenses/>. */
      18  
      19  #include "tree_types.h"
      20  
      21  enum context {
      22      ct_NONE,
      23      ct_line,
      24      ct_def,
      25      ct_preformatted,
      26      ct_rawpreformatted,
      27      ct_math,
      28      ct_brace_command,
      29      ct_inlineraw,
      30  };
      31  
      32  /* Contexts where an empty line doesn't start a new paragraph. */
      33  #define in_paragraph_context(c) \
      34    !((c) == ct_math \
      35     || (c) == ct_def \
      36     || (c) == ct_preformatted \
      37     || (c) == ct_rawpreformatted \
      38     || (c) == ct_inlineraw)
      39  
      40  void push_context (enum context c, enum command_id cmd);
      41  enum context pop_context (void);
      42  enum context current_context (void);
      43  void reset_context_stack (void);
      44  int in_context (enum context context);
      45  char *context_name (enum context c);
      46  
      47  
      48  
      49  
      50  typedef struct {
      51    enum command_id *stack;
      52    size_t top;   /* One above last pushed context. */
      53    size_t space;
      54  } COMMAND_STACK;
      55  
      56  void reset_command_stack (COMMAND_STACK *stack);
      57  void push_command (COMMAND_STACK *stack, enum command_id cmd);
      58  enum command_id pop_command (COMMAND_STACK *stack);
      59  enum command_id top_command (COMMAND_STACK *stack);
      60  enum command_id current_context_command (void);
      61  
      62  
      63  /* Used to check indirect nesting, e.g. @footnote{@emph{@footnote{...}}} */
      64  typedef struct {
      65      int footnote;
      66      int caption;
      67      COMMAND_STACK basic_inline_stack;
      68      COMMAND_STACK basic_inline_stack_on_line;
      69      COMMAND_STACK basic_inline_stack_block;
      70      COMMAND_STACK regions_stack;
      71  } NESTING_CONTEXT;
      72  
      73  extern NESTING_CONTEXT nesting_context;
      74  
      75  
      76  int in_preformatted_context_not_menu(void);
      77  #endif