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) 
|
Go to the documentation of this file. 58 static int max(
int i1,
int i2)
60 return i1 >= i2 ? i1 : i2;
63 static int min(
int i1,
int i2)
65 return i1 <= i2 ? i1 : i2;
176 const char *deletedText =
text();
181 int insertedLength = (int) strlen(t);
186 memcpy(
mBuf, t, insertedLength);
193 free((
void *) deletedText);
208 if (start < 0 || start >
mLength)
221 int copiedLength = end -
start;
222 s = (
char *)
malloc(copiedLength + 1);
232 memcpy(s + part1Length,
mBuf +
mGapEnd, copiedLength - part1Length);
234 s[copiedLength] =
'\0';
248 const char *src =
address(pos);
260 const char *src =
address(pos);
319 free((
void *) deletedText);
356 free((
void *) deletedText);
365 int fromEnd,
int toPos)
371 int copiedLength = fromEnd - fromStart;
385 memcpy(&
mBuf[toPos], &fromBuf->
mBuf[fromStart], copiedLength);
386 }
else if (fromStart >= fromBuf->
mGapStart) {
391 int part1Length = fromBuf->
mGapStart - fromStart;
392 memcpy(&
mBuf[toPos], &fromBuf->
mBuf[fromStart], part1Length);
393 memcpy(&
mBuf[toPos + part1Length],
394 &fromBuf->
mBuf[fromBuf->
mGapEnd], copiedLength - part1Length);
475 const char *deletedText =
text();
477 free((
void *) deletedText);
666 newModifyProcs[0] = bufModifiedCB;
667 newCBArgs[0] = cbArg;
680 int i, toRemove = -1;
689 if (toRemove == -1) {
691 (
"Fl_Text_Buffer::remove_modify_callback(): Can't find modify CB to remove");
710 for (i = 0; i < toRemove; i++) {
742 newPreDeleteProcs[0] = bufPreDeleteCB;
743 newCBArgs[0] = cbArg;
755 int i, toRemove = -1;
764 if (toRemove == -1) {
766 (
"Fl_Text_Buffer::remove_predelete_callback(): Can't find pre-delete CB to remove");
783 for (i = 0; i < toRemove; i++) {
869 int pos = lineStartPos;
870 while (pos < targetPos) {
886 int pos = lineStartPos;
888 for (
int charCount = 0; charCount < nChars && pos <
mLength; charCount++) {
915 if (
mBuf[pos++] ==
'\n')
921 if (
mBuf[pos++ + gapLen] ==
'\n')
944 if (
mBuf[pos++] ==
'\n') {
946 if (lineCount == nLines) {
953 if (
mBuf[pos++ + gapLen] ==
'\n') {
955 if (lineCount >= nLines) {
975 int pos = startPos - 1;
982 if (
mBuf[pos + gapLen] ==
'\n') {
983 if (++lineCount >= nLines) {
991 if (
mBuf[pos] ==
'\n') {
992 if (++lineCount >= nLines) {
1007 int *foundPos,
int matchCase)
const 1017 while (startPos <
length()) {
1024 *foundPos = startPos;
1028 if (memcmp(sp,
address(bp), l))
1035 while (startPos <
length()) {
1041 *foundPos = startPos;
1059 int *foundPos,
int matchCase)
const 1069 while (startPos >= 0) {
1076 *foundPos = startPos;
1080 if (memcmp(sp,
address(bp), l))
1087 while (startPos >= 0) {
1093 *foundPos = startPos;
1121 int insertedLength = (int) strlen(
text);
1134 memcpy(&
mBuf[pos],
text, insertedLength);
1146 undoat = pos + insertedLength;
1151 return insertedLength;
1252 char *s = (
char *)
malloc(1);
1306 int nInserted,
int nRestyled,
1307 const char *deletedText)
const {
1310 (*
mModifyProcs[i]) (pos, nInserted, nDeleted, nRestyled,
1334 int oldStart, oldEnd, newStart, newEnd, ch1Start, ch1End, ch2Start,
1340 oldStart = oldSelection->
mStart;
1341 newStart = newSelection->
mStart;
1342 oldEnd = oldSelection->
mEnd;
1343 newEnd = newSelection->
mEnd;
1361 if (oldEnd < newStart || newEnd < oldStart) {
1370 ch1Start =
min(oldStart, newStart);
1371 ch2End =
max(oldEnd, newEnd);
1372 ch1End =
max(oldStart, newStart);
1373 ch2Start =
min(oldEnd, newEnd);
1374 if (ch1Start != ch1End)
1376 if (ch2Start != ch2End)
1405 int newGapEnd = newGapStart + newGapLen;
1408 memcpy(newBuf,
mBuf, newGapStart);
1409 memcpy(&newBuf[newGapEnd], &
mBuf[newGapStart],
1411 memcpy(&newBuf[newGapEnd +
mGapStart - newGapStart],
1416 memcpy(&newBuf[newGapEnd],
1445 if (pos + nDeleted <=
mStart) {
1446 mStart += nInserted - nDeleted;
1447 mEnd += nInserted - nDeleted;
1448 }
else if (pos <= mStart && pos + nDeleted >=
mEnd) {
1452 }
else if (pos <=
mStart && pos + nDeleted <
mEnd) {
1454 mEnd = nInserted +
mEnd - nDeleted;
1455 }
else if (pos <
mEnd) {
1456 mEnd += nInserted - nDeleted;
1468 int *foundPos)
const 1479 if (searchChar ==
char_at(startPos)) {
1480 *foundPos = startPos;
1495 int *foundPos)
const {
1496 if (startPos <= 0) {
1505 if (searchChar ==
char_at(startPos)) {
1506 *foundPos = startPos;
1516 #ifdef EXAMPLE_ENCODING 1519 unsigned cp1252toucs(
char* &
p)
1523 static unsigned cp1252[32] = {
1524 0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
1525 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
1526 0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
1527 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178
1529 unsigned char uc = *(
unsigned char*)
p;
1531 return (uc < 0x80 || uc >= 0xa0 ? uc :
cp1252[uc - 0x80]);
1535 unsigned utf16toucs(
char* &
p)
1539 struct {
unsigned char a,
b;}
chars;
1541 struct {
unsigned char b, a;}
chars;
1545 u.chars.a = *(
unsigned char*)
p++;
1546 u.chars.b = *(
unsigned char*)
p++;
1556 static int general_input_filter(
char *
buffer,
int buflen,
1557 char *line,
int sline,
char* &
endline,
1558 unsigned (*p_trf)(
char* &),
1561 char *
p, *q, multibyte[5];
1567 r = fread(line, 1, sline, fp);
1569 if (r == 0)
return q -
buffer;
1578 memcpy(q, multibyte, lq);
1585 #endif // EXAMPLE_ENCODING 1604 int *input_was_changed)
1613 char *
p, *q, multibyte[5];
1620 r = (int) fread(line, 1, sline, fp);
1622 if (r == 0)
return (
int) (q -
buffer);
1636 if (
endline - line < l)
break;
1641 if (lp != l || lq != l) *input_was_changed =
true;
1646 return (
int) (q -
buffer);
1648 memcpy(q, multibyte, lq);
1656 return (
int) (q -
buffer);
1660 "Displayed text contains the UTF-8 transcoding\n" 1661 "of the input file which was not UTF-8 encoded.\n" 1662 "Some changes may have occurred.";
1681 #ifdef EXAMPLE_ENCODING 1697 int e = ferror(fp) ? 2 : 0;
1719 int r = (int) fwrite(
p, 1, n, fp);
1725 int e = ferror(fp) ? 2 : 0;
1748 }
while ( (c&0xc0) == 0x80);
1761 if (pos==0)
return -1;
1797 while ( (c&0xc0) == 0x80) {
static int min(int i1, int i2)
void(* transcoding_warning_action)(Fl_Text_Buffer *)
Pointer to a function called after reading a non UTF-8 encoded file.
Fl_Text_Buffer(int requestedSize=0, int preferredGapSize=1024)
char * line_text(int pos) const
int secondary_selection_position(int *start, int *end)
void secondary_unselect()
int start() const
Return the byte offset to the first selected character.
#define IS_UTF8_ALIGNED2(a, b)
This is an internal class for Fl_Text_Buffer to manage text selections. This class works correctly wi...
int line_end(int pos) const
int findchar_backward(int startPos, unsigned int searchChar, int *foundPos) const
static const Fl_Glut_StrokeChar * chars[]
Fl_Text_Predelete_Cb * mPredeleteProcs
int skip_lines(int startPos, int nLines)
char * text_range(int start, int end) const
Get a copy of a part of the text buffer. Return a copy of the text between start and end character po...
void canUndo(char flag=1)
void insert(int pos, const char *text)
int input_file_was_transcoded
true if the loaded file has been transcoded to UTF-8.
int rewind_lines(int startPos, int nLines)
Fl_Text_Selection mHighlight
const char * address(int pos) const
void replace_selection(const char *text)
int prev_char(int ix) const
void add_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void *cbArg)
FILE * fl_fopen(const char *f, const char *mode)
int length() const
Returns the number of bytes in the buffer.
int word_start(int pos) const
unsigned int char_at(int pos) const
void remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void *cbArg)
static void undobuffersize(int n)
unsigned fl_utf8decode(const char *p, const char *end, int *len)
int position(int *start, int *end) const
Return the positions of this selection.
void remove(int start, int end)
int utf8_align(int) const
int search_backward(int startPos, const char *searchString, int *foundPos, int matchCase=0) const
int count_displayed_characters(int lineStartPos, int targetPos) const
void(* Fl_Text_Predelete_Cb)(int pos, int nDeleted, void *cbArg)
header for Unicode and UTF-8 character handling
Fl_Text_Selection mSecondary
int word_end(int pos) const
int outputfile(const char *file, int start, int end, int buflen=128 *1024)
int mEnd
byte offset to the character after the last selected character
void remove_selection_(Fl_Text_Selection *sel)
int skip_displayed_characters(int lineStartPos, int nChars)
static int max(int i1, int i2)
void update_selections(int pos, int nDeleted, int nInserted)
void remove_(int start, int end)
int next_char(int ix) const
bool selected() const
Returns true if any text is selected.
int selection_position(int *start, int *end)
char byte_at(int pos) const
void update(int pos, int nDeleted, int nInserted)
Updates a selection after text was modified.
void call_predelete_callbacks()
void replace_selection_(Fl_Text_Selection *sel, const char *text)
void select(int start, int end)
void secondary_select(int start, int end)
char * text() const
Get a copy of the entire contents of the text buffer. Memory is allocated to contain the returned str...
void add_predelete_callback(Fl_Text_Predelete_Cb bufPredelCB, void *cbArg)
void(* Fl_Text_Modify_Cb)(int pos, int nInserted, int nDeleted, int nRestyled, const char *deletedText, void *cbArg)
int count_lines(int startPos, int endPos) const
void remove_secondary_selection()
void replace_secondary_selection(const char *text)
int highlight_position(int *start, int *end)
char * secondary_selection_text()
int next_char_clipped(int ix) const
int fl_utf8encode(unsigned ucs, char *buf)
int end() const
Return the byte offset to the character after the last selected character.
int includes(int pos) const
Fl_Text_Selection mPrimary
void set(int start, int end)
Set the selection range.
int mStart
byte offset to the first selected character
int prev_char_clipped(int ix) const
void redisplay_selection(Fl_Text_Selection *oldSelection, Fl_Text_Selection *newSelection) const
void replace(int start, int end, const char *text)
static int utf8_input_filter(char *buffer, int buflen, char *line, int sline, char *&endline, FILE *fp, int *input_was_changed)
static unsigned short cp1252[32]
char * selection_text_(Fl_Text_Selection *sel) const
static Fl_Text_Buffer * undowidget
void reallocate_with_gap(int newGapStart, int newGapLen)
void remove_predelete_callback(Fl_Text_Predelete_Cb predelCB, void *cbArg)
static int undobufferlength
Fl_Text_Modify_Cb * mModifyProcs
int insertfile(const char *file, int pos, int buflen=128 *1024)
int insert_(int pos, const char *text)
int search_forward(int startPos, const char *searchString, int *foundPos, int matchCase=0) const
static void(* error)(const char *,...)
int line_start(int pos) const
static const char * file_encoding_warning_message
#define IS_UTF8_ALIGNED(a)
This class manages Unicode text displayed in one or more Fl_Text_Display widgets.
static int start(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int w, int h, int &cx, int &cy, int &X, int &Y, int &W, int &H)
void copy(Fl_Text_Buffer *fromBuf, int fromStart, int fromEnd, int toPos)
void fl_alert(const char *,...)
static void def_transcoding_warning_action(Fl_Text_Buffer *text)
int fl_tolower(unsigned int ucs)
bool mSelected
this flag is set if any text is selected
void call_modify_callbacks()
int findchar_forward(int startPos, unsigned searchChar, int *foundPos) const