print_ctxt.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * @file print_ctxt.h
  3. *
  4. * Defines a context used during element printing and all it's
  5. * associated functions.
  6. */
  7. /*
  8. * This program is free software: you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation, either vers* ion 3 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see
  20. * <http://www.gnu.org/licenses/>.
  21. */
  22. #ifndef PRINT_CTXT_H
  23. #define PRINT_CTXT_H
  24. #include "stdbool.h"
  25. /**
  26. * @brief A context for the current printing mode.
  27. *
  28. * It acts as a request to print only certain information. It does
  29. * not imply what side of a conflict we are printing.
  30. */
  31. typedef enum print_state
  32. {
  33. print_merged,
  34. print_remote,
  35. print_local,
  36. print_ancestor
  37. } print_state;
  38. /**
  39. * @brief The current state of conflict markers.
  40. */
  41. typedef enum conflict_state
  42. {
  43. no_conflict = 0,
  44. local_side = 1,
  45. remote_side = 2
  46. } conflict_state;
  47. /**
  48. * @brief A context for printing doc_elt's in a tree.
  49. */
  50. typedef struct print_ctxt
  51. {
  52. int depth; /*< The current depth in a document tree */
  53. size_t current_level; /*< the current level of a document */
  54. size_t rmargin; /*< The column of the doc's right margin */
  55. size_t tab_width; /*< The column width of a tab character */
  56. bool use_tabs; /*< Should generated output use tabs? */
  57. print_state print_state; /*< the current printing mode */
  58. bool nested_conflicts; /*< if there are nested conflicts */
  59. conflict_state structure_conflict; /*< the current state of conflicts */
  60. conflict_state content_conflict; /*< the current state of conflicts */
  61. conflict_state movement_conflict; /*< the current state of conflict */
  62. bool conflict_occurred; /*< IF a conflict occured */
  63. } print_ctxt;
  64. /**
  65. * @brief Create and initialize a print context.
  66. */
  67. print_ctxt* print_ctxt_create_empty (void);
  68. /**
  69. * @brief Initialize a print_ctxt.
  70. */
  71. void print_ctxt_init (print_ctxt *ctxt);
  72. #endif