fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Browser_load.cxx
Go to the documentation of this file.
1 //
2 // "$Id$"
3 //
4 // File loading routines 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 
19 #include <FL/Fl.H>
20 #include <FL/Fl_Browser.H>
21 #include <stdio.h>
22 #include <FL/fl_utf8.h>
23 
35 int Fl_Browser::load(const char *filename) {
36 #define MAXFL_BLINE 1024
37  char newtext[MAXFL_BLINE];
38  int c;
39  int i;
40  clear();
41  if (!filename || !(filename[0])) return 1;
42  FILE *fl = fl_fopen(filename,"r");
43  if (!fl) return 0;
44  i = 0;
45  do {
46  c = getc(fl);
47  if (c == '\n' || c <= 0 || i>=(MAXFL_BLINE-1)) {
48  newtext[i] = 0;
49  add(newtext);
50  i = 0;
51  } else {
52  newtext[i++] = c;
53  }
54  } while (c >= 0);
55  fclose(fl);
56  return 1;
57 }
58 
59 //
60 // End of "$Id$".
61 //
Fl_Browser::load
int load(const char *filename)
Definition: Fl_Browser_load.cxx:35
Fl.H
fl_fopen
FILE * fl_fopen(const char *f, const char *mode)
Definition: fl_utf8.cxx:498
fl_utf8.h
header for Unicode and UTF-8 character handling
filename
static const char * filename
Definition: fluid.cxx:119
Fl_Browser.H
MAXFL_BLINE
#define MAXFL_BLINE
Fl_Browser::add
void add(const char *newtext, void *d=0)
Definition: Fl_Browser.cxx:710
Fl_Browser::clear
void clear()
Definition: Fl_Browser.cxx:685