BKE_suggestions.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2008, Blender Foundation
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. #ifndef __BKE_SUGGESTIONS_H__
  28. #define __BKE_SUGGESTIONS_H__
  29. /** \file BKE_suggestions.h
  30. * \ingroup bke
  31. */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /* ****************************************************************************
  36. * Suggestions should be added in sorted order although a linear sorting method is
  37. * implemented. The list is then divided up based on the prefix provided by
  38. * update_suggestions:
  39. *
  40. * Example:
  41. * Prefix: ab
  42. * aaa <-- first
  43. * aab
  44. * aba <-- firstmatch
  45. * abb <-- lastmatch
  46. * baa
  47. * bab <-- last
  48. **************************************************************************** */
  49. struct Text;
  50. typedef struct SuggItem {
  51. struct SuggItem *prev, *next;
  52. char type;
  53. char name[0];
  54. } SuggItem;
  55. typedef struct SuggList {
  56. SuggItem *first, *last;
  57. SuggItem *firstmatch, *lastmatch;
  58. SuggItem *selected;
  59. int top;
  60. } SuggList;
  61. /* Free all text tool memory */
  62. void free_texttools(void);
  63. /* Used to identify which Text object the current tools should appear against */
  64. void texttool_text_set_active(Text *text);
  65. void texttool_text_clear(void);
  66. short texttool_text_is_active(Text *text);
  67. /* Suggestions */
  68. void texttool_suggest_add(const char *name, char type);
  69. void texttool_suggest_prefix(const char *prefix, const int prefix_len);
  70. void texttool_suggest_clear(void);
  71. SuggItem *texttool_suggest_first(void);
  72. SuggItem *texttool_suggest_last(void);
  73. void texttool_suggest_select(SuggItem *sel);
  74. SuggItem *texttool_suggest_selected(void);
  75. int *texttool_suggest_top(void);
  76. /* Documentation */
  77. void texttool_docs_show(const char *docs);
  78. char *texttool_docs_get(void);
  79. void texttool_docs_clear(void);
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif