org_heading.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * @file org_heading.h
  3. * @brief Defines an org mode heading
  4. */
  5. /*
  6. * This program is free software: you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either vers* ion 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * 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
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef ORG_HEADING_H
  21. #define ORG_HEADING_H
  22. #include "stddef.h"
  23. #include "stdbool.h"
  24. /* org_text forward declaration */
  25. struct org_text;
  26. typedef struct org_text org_text;
  27. /* org_heading forward declaration */
  28. struct org_heading;
  29. typedef struct org_heading org_heading;
  30. typedef struct doc_elt_ops doc_elt_ops;
  31. extern doc_elt_ops org_heading_ops;
  32. /* Constructor, Destructor */
  33. /**
  34. * @brief Construct an empty org heading element.
  35. */
  36. org_heading *org_heading_create_empty (doc_elt_ops *elt_ops);
  37. /**
  38. * @brief Free an org heading.
  39. */
  40. void org_heading_free (org_heading *self);
  41. /* Getters and Setters */
  42. int org_heading_get_level (org_heading *self, doc_src src);
  43. void org_heading_set_level (org_heading *self, int level, doc_src src);
  44. doc_ref* org_heading_get_doc_ref (org_heading *heading);
  45. void org_heading_set_doc_ref (org_heading *heading, doc_ref *ref);
  46. /**
  47. * @brief Set the entire text of a heading.
  48. *
  49. * This function expects a single line storing an entire heading,
  50. * including leading stars and any trailing line breaks. The line
  51. * will be parsed, and any internal variables will be set. The string
  52. * is not null terminated.
  53. */
  54. void org_heading_set_entire_text (org_heading *self, char *string, int length,
  55. doc_src src, parse_ctxt *ctxt);
  56. /**
  57. * @brief Set the key of a heading.
  58. * This key will be used to identify the heading globally.
  59. * Set the key to an empty key to disable global matching.
  60. * The key can be accessed through doc_elt_get_key.
  61. */
  62. void org_heading_set_key (org_heading *self, char*key, size_t length);
  63. /* Adding sub elements */
  64. /**
  65. * @brief Add a doc_elt as the last item in the list of text
  66. * subelements.
  67. */
  68. void org_heading_add_subtext_last (org_heading *heading, doc_src src,
  69. doc_elt *elt);
  70. /**
  71. * @brief Add a doc_elt as the last item in the list of heading
  72. * subelements.
  73. */
  74. void org_heading_add_subheading_last (org_heading *heading, doc_src src,
  75. doc_elt *elt);
  76. /**
  77. * @brief Set the values of a heading, using information stored in the
  78. * ctxt */
  79. void org_heading_set_parse_ctxt (org_heading *heading, doc_src src, parse_ctxt *ctxt);
  80. bool org_heading_check_for_target (org_heading *this, org_heading* target);
  81. /* will call the function on its children after it searches for
  82. itself */
  83. bool org_heading_check_for_loop (org_heading *this);
  84. #endif