You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.3KB

  1. //
  2. // "$Id: texteditor-simple.cxx 8183 2011-01-04 17:31:56Z AlbrechtS $"
  3. //
  4. // A simple example of Fl_Text_Editor
  5. //
  6. // Fl_Text_Editor is unlike other FLTK widgets in that
  7. // to work correctly, it must be assigned to an instance of an
  8. // Fl_Text_Buffer. The below shows using buffer() to connect
  9. // the two classes together.
  10. //
  11. // Note that the example can also be used to demonstrate
  12. // Fl_Text_Display; just replace all instances of
  13. // Fl_Text_Editor with Fl_Text_Display and rebuild.
  14. //
  15. // Copyright 2010 Greg Ercolano.
  16. // Copyright 1998-2010 by Bill Spitzak and others.
  17. //
  18. // This library is free software; you can redistribute it and/or
  19. // modify it under the terms of the GNU Library General Public
  20. // License as published by the Free Software Foundation; either
  21. // version 2 of the License, or (at your option) any later version.
  22. //
  23. // This library is distributed in the hope that it will be useful,
  24. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. // Library General Public License for more details.
  27. //
  28. // You should have received a copy of the GNU Library General Public
  29. // License along with this library; if not, write to the Free Software
  30. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  31. // USA.
  32. //
  33. // Please report all bugs and problems on the following page:
  34. //
  35. // http://www.fltk.org/str.php
  36. //
  37. #include <FL/Fl.H>
  38. #include <FL/Fl_Double_Window.H>
  39. #include <FL/Fl_Text_Editor.H>
  40. int main() {
  41. Fl_Double_Window *win = new Fl_Double_Window(640, 480, "Simple Fl_Text_Editor");
  42. Fl_Text_Buffer *buff = new Fl_Text_Buffer();
  43. Fl_Text_Editor *edit = new Fl_Text_Editor(20, 20, 640-40, 480-40);
  44. edit->buffer(buff); // attach the text buffer to our editor widget
  45. win->resizable(*edit);
  46. win->show();
  47. buff->text("line 0\nline 1\nline 2\n"
  48. "line 3\nline 4\nline 5\n"
  49. "line 6\nline 7\nline 8\n"
  50. "line 9\nline 10\nline 11\n"
  51. "line 12\nline 13\nline 14\n"
  52. "line 15\nline 16\nline 17\n"
  53. "line 18\nline 19\nline 20\n"
  54. "line 21\nline 22\nline 23\n");
  55. return(Fl::run());
  56. }
  57. //
  58. // End of "$Id: texteditor-simple.cxx 8183 2011-01-04 17:31:56Z AlbrechtS $".
  59. //