CodeEditor.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // "$Id: CodeEditor.h 9980 2013-09-21 16:41:23Z greg.ercolano $"
  3. //
  4. // Code editor widget for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. #ifndef CodeEditor_h
  19. # define CodeEditor_h
  20. //
  21. // Include necessary headers...
  22. //
  23. # include <stdio.h>
  24. # include <stdlib.h>
  25. # include <string.h>
  26. # include <ctype.h>
  27. # include <FL/Fl.H>
  28. # include <FL/Fl_Text_Buffer.H>
  29. # include <FL/Fl_Text_Editor.H>
  30. class CodeEditor : public Fl_Text_Editor {
  31. static Fl_Text_Display::Style_Table_Entry styletable[];
  32. static const char * const code_keywords[];
  33. static const char * const code_types[];
  34. // 'compare_keywords()' - Compare two keywords...
  35. static int compare_keywords(const void *a, const void *b);
  36. // 'style_parse()' - Parse text and produce style data.
  37. static void style_parse(const char *text, char *style, int length);
  38. // 'style_unfinished_cb()' - Update unfinished styles.
  39. static void style_unfinished_cb(int, void*);
  40. // 'style_update()' - Update the style buffer...
  41. static void style_update(int pos, int nInserted, int nDeleted,
  42. int /*nRestyled*/, const char * /*deletedText*/,
  43. void *cbArg);
  44. static int auto_indent(int, CodeEditor* e);
  45. public:
  46. CodeEditor(int X, int Y, int W, int H, const char *L=0);
  47. ~CodeEditor();
  48. int top_line() { return get_absolute_top_line_number(); }
  49. // attempt to make the fluid code editor widget honour textsize setting
  50. void textsize(Fl_Fontsize s);
  51. void change_text_size(int fsize);
  52. };
  53. class CodeViewer : public CodeEditor {
  54. public:
  55. CodeViewer(int X, int Y, int W, int H, const char *L=0);
  56. protected:
  57. int handle(int ev);
  58. };
  59. #endif // !CodeEditor_h
  60. //
  61. // End of "$Id: CodeEditor.h 9980 2013-09-21 16:41:23Z greg.ercolano $".
  62. //