Blame examples/texteditor-simple.cxx

Packit 328d5c
//
Packit 328d5c
// "$Id: texteditor-simple.cxx 8864 2011-07-19 04:49:30Z greg.ercolano $"
Packit 328d5c
//
Packit 328d5c
//	A simple example of Fl_Text_Editor
Packit 328d5c
//
Packit 328d5c
//	Fl_Text_Editor is unlike other FLTK widgets in that
Packit 328d5c
//	to work correctly, it must be assigned to an instance of an
Packit 328d5c
//	Fl_Text_Buffer.  The below shows using buffer() to connect
Packit 328d5c
//	the two classes together.
Packit 328d5c
//
Packit 328d5c
//	Note that the example can also be used to demonstrate
Packit 328d5c
//	Fl_Text_Display; just replace all instances of
Packit 328d5c
//	Fl_Text_Editor with Fl_Text_Display and rebuild.
Packit 328d5c
//
Packit 328d5c
// Copyright 2010 Greg Ercolano.
Packit 328d5c
// Copyright 1998-2010 by Bill Spitzak and others.
Packit 328d5c
//
Packit 328d5c
// This library is free software. Distribution and use rights are outlined in
Packit 328d5c
// the file "COPYING" which should have been included with this file.  If this
Packit 328d5c
// file is missing or damaged, see the license at:
Packit 328d5c
//
Packit 328d5c
//     http://www.fltk.org/COPYING.php
Packit 328d5c
//
Packit 328d5c
// Please report all bugs and problems on the following page:
Packit 328d5c
//
Packit 328d5c
//     http://www.fltk.org/str.php
Packit 328d5c
//
Packit 328d5c
Packit 328d5c
#include <FL/Fl.H>
Packit 328d5c
#include <FL/Fl_Double_Window.H>
Packit 328d5c
#include <FL/Fl_Text_Editor.H>
Packit 328d5c
Packit 328d5c
int main() {
Packit 328d5c
     Fl_Double_Window *win  = new Fl_Double_Window(640, 480, "Simple Fl_Text_Editor");
Packit 328d5c
     Fl_Text_Buffer   *buff = new Fl_Text_Buffer();
Packit 328d5c
     Fl_Text_Editor   *edit = new Fl_Text_Editor(20, 20, 640-40, 480-40);
Packit 328d5c
     edit->buffer(buff);		// attach the text buffer to our editor widget
Packit 328d5c
     win->resizable(*edit);
Packit 328d5c
     win->show();
Packit 328d5c
     buff->text("line 0\nline 1\nline 2\n"
Packit 328d5c
                "line 3\nline 4\nline 5\n"
Packit 328d5c
                "line 6\nline 7\nline 8\n"
Packit 328d5c
                "line 9\nline 10\nline 11\n"
Packit 328d5c
                "line 12\nline 13\nline 14\n"
Packit 328d5c
                "line 15\nline 16\nline 17\n"
Packit 328d5c
                "line 18\nline 19\nline 20\n"
Packit 328d5c
                "line 21\nline 22\nline 23\n");
Packit 328d5c
     return(Fl::run());
Packit 328d5c
}
Packit 328d5c
Packit 328d5c
//
Packit 328d5c
// End of "$Id: texteditor-simple.cxx 8864 2011-07-19 04:49:30Z greg.ercolano $".
Packit 328d5c
//