Browse Source

UTF8: Fl_Text_Display and related:

+ Added more const constraints to Fl_Text_Selection and Fl_Text_Buffer methods.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6819 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/49/head
Fabien Costantini 16 years ago
parent
commit
e982ba24a9
  1. 40
      FL/Fl_Text_Buffer.H
  2. 22
      src/Fl_Text_Buffer.cxx

40
FL/Fl_Text_Buffer.H

@ -51,20 +51,20 @@ class FL_EXPORT Fl_Text_Selection { @@ -51,20 +51,20 @@ class FL_EXPORT Fl_Text_Selection {
void set(int start, int end);
void set_rectangular(int start, int end, int rectStart, int rectEnd);
void update(int pos, int nDeleted, int nInserted);
char rectangular() { return mRectangular; }
int start() { return mStart; }
int end() { return mEnd; }
int rect_start() { return mRectStart; }
int rect_end() { return mRectEnd; }
char rectangular() const { return mRectangular; }
int start() const { return mStart; }
int end() const { return mEnd; }
int rect_start() const { return mRectStart; }
int rect_end() const { return mRectEnd; }
/**
Returns a non-zero number if any text has been selected, or 0
if no text is selected.
*/
char selected() { return mSelected; }
char selected() const { return mSelected; }
void selected(char b) { mSelected = b; }
int includes(int pos, int lineStartPos, int dispIndex);
int position(int* start, int* end);
int position(int* start, int* end, int* isRect, int* rectStart, int* rectEnd);
int includes(int pos, int lineStartPos, int dispIndex) const;
int position(int* start, int* end) const;
int position(int* start, int* end, int* isRect, int* rectStart, int* rectEnd) const;
protected:
@ -101,11 +101,11 @@ class FL_EXPORT Fl_Text_Buffer { @@ -101,11 +101,11 @@ class FL_EXPORT Fl_Text_Buffer {
~Fl_Text_Buffer();
/** Returns the number of characters in the buffer. */
int length() { return mLength; }
int length() const { return mLength; }
char* text() const;
void text(const char* text);
char* text_range(int start, int end);
char character(int pos);
char* text_range(int start, int end) const;
char character(int pos) const;
char* text_in_rectangle(int start, int end, int rectStart, int rectEnd);
void insert(int pos, const char* text);
/** Appends the text string to the end of the buffer. */
@ -145,11 +145,11 @@ class FL_EXPORT Fl_Text_Buffer { @@ -145,11 +145,11 @@ class FL_EXPORT Fl_Text_Buffer {
void remove_rectangular(int start, int end, int rectStart, int rectEnd);
void clear_rectangular(int start, int end, int rectStart, int rectEnd);
/** Gets the tab width. */
int tab_distance() { return mTabDist; }
int tab_distance() const { return mTabDist; }
void tab_distance(int tabDist);
void select(int start, int end);
/** Returns a non 0 value if text has been selected, 0 otherwise */
int selected() { return mPrimary.selected(); }
int selected() const { return mPrimary.selected(); }
void unselect();
void select_rectangular(int start, int end, int rectStart, int rectEnd);
int selection_position(int* start, int* end);
@ -226,16 +226,16 @@ class FL_EXPORT Fl_Text_Buffer { @@ -226,16 +226,16 @@ class FL_EXPORT Fl_Text_Buffer {
int count_lines(int startPos, int endPos);
int skip_lines(int startPos, int nLines);
int rewind_lines(int startPos, int nLines);
int findchar_forward(int startPos, char searchChar, int* foundPos);
int findchar_backward(int startPos, char searchChar, int* foundPos);
int findchars_forward(int startPos, const char* searchChars, int* foundPos);
int findchars_backward(int startPos, const char* searchChars, int* foundPos);
int findchar_forward(int startPos, char searchChar, int* foundPos) const;
int findchar_backward(int startPos, char searchChar, int* foundPos) const;
int findchars_forward(int startPos, const char* searchChars, int* foundPos) const;
int findchars_backward(int startPos, const char* searchChars, int* foundPos) const;
int search_forward(int startPos, const char* searchString, int* foundPos,
int matchCase = 0);
int matchCase = 0) const;
int search_backward(int startPos, const char* searchString, int* foundPos,
int matchCase = 0);
int matchCase = 0) const;
int substitute_null_characters(char* string, int length);
void unsubstitute_null_characters(char* string);

22
src/Fl_Text_Buffer.cxx

@ -202,7 +202,7 @@ void Fl_Text_Buffer::text(const char *t) { @@ -202,7 +202,7 @@ void Fl_Text_Buffer::text(const char *t) {
include the character pointed to by \p end.
When you are done with the text, free it using the free() function.
*/
char * Fl_Text_Buffer::text_range(int start, int end) {
char * Fl_Text_Buffer::text_range(int start, int end) const {
char * s = NULL;
int copiedLength, part1Length;
@ -239,7 +239,7 @@ char * Fl_Text_Buffer::text_range(int start, int end) { @@ -239,7 +239,7 @@ char * Fl_Text_Buffer::text_range(int start, int end) {
/** Returns the character at the specified position pos in the buffer.
Positions start at 0 */
char Fl_Text_Buffer::character(int pos) {
char Fl_Text_Buffer::character(int pos) const {
if (pos < 0 || pos >= mLength)
return '\0';
if (pos < mGapStart)
@ -1177,7 +1177,7 @@ int Fl_Text_Buffer::rewind_lines(int startPos, int nLines) { @@ -1177,7 +1177,7 @@ int Fl_Text_Buffer::rewind_lines(int startPos, int nLines) {
returns 1 if found, 0 if not.
*/
int Fl_Text_Buffer::search_forward(int startPos, const char *searchString,
int *foundPos, int matchCase)
int *foundPos, int matchCase) const
{
if (!searchString) return 0;
int bp;
@ -1201,7 +1201,7 @@ int Fl_Text_Buffer::search_forward(int startPos, const char *searchString, @@ -1201,7 +1201,7 @@ int Fl_Text_Buffer::search_forward(int startPos, const char *searchString,
returns 1 if found, 0 if not.
*/
int Fl_Text_Buffer::search_backward(int startPos, const char *searchString,
int *foundPos, int matchCase)
int *foundPos, int matchCase) const
{
if (!searchString) return 0;
int bp;
@ -1226,7 +1226,7 @@ int Fl_Text_Buffer::search_backward(int startPos, const char *searchString, @@ -1226,7 +1226,7 @@ int Fl_Text_Buffer::search_backward(int startPos, const char *searchString,
returns 1 if found, 0 if not.
*/
int Fl_Text_Buffer::findchars_forward(int startPos, const char *searchChars,
int *foundPos) {
int *foundPos) const {
int pos, gapLen = mGapEnd - mGapStart;
const char *c;
@ -1260,7 +1260,7 @@ int Fl_Text_Buffer::findchars_forward(int startPos, const char *searchChars, @@ -1260,7 +1260,7 @@ int Fl_Text_Buffer::findchars_forward(int startPos, const char *searchChars,
returns 1 if found, 0 if not.
*/
int Fl_Text_Buffer::findchars_backward(int startPos, const char *searchChars,
int *foundPos) {
int *foundPos) const {
int pos, gapLen = mGapEnd - mGapStart;
const char *c;
@ -1975,7 +1975,7 @@ void Fl_Text_Selection::set_rectangular(int startpos, int endpos, @@ -1975,7 +1975,7 @@ void Fl_Text_Selection::set_rectangular(int startpos, int endpos,
mRectEnd = rectEnd;
}
int Fl_Text_Selection::position(int *startpos, int *endpos) {
int Fl_Text_Selection::position(int *startpos, int *endpos) const {
if (!mSelected)
return 0;
*startpos = mStart;
@ -1985,7 +1985,7 @@ int Fl_Text_Selection::position(int *startpos, int *endpos) { @@ -1985,7 +1985,7 @@ int Fl_Text_Selection::position(int *startpos, int *endpos) {
}
int Fl_Text_Selection::position(int *startpos, int *endpos,
int *isRect, int *rectStart, int *rectEnd) {
int *isRect, int *rectStart, int *rectEnd) const {
if (!mSelected)
return 0;
*isRect = mRectangular;
@ -2002,7 +2002,7 @@ int Fl_Text_Selection::position(int *startpos, int *endpos, @@ -2002,7 +2002,7 @@ int Fl_Text_Selection::position(int *startpos, int *endpos,
Return true if position \p pos with indentation \p dispIndex is in
the Fl_Text_Selection.
*/
int Fl_Text_Selection::includes(int pos, int lineStartPos, int dispIndex) {
int Fl_Text_Selection::includes(int pos, int lineStartPos, int dispIndex) const {
return selected() &&
((!rectangular() && pos >= start() && pos < end()) ||
(rectangular() && pos >= start() && lineStartPos <= end() &&
@ -2272,7 +2272,7 @@ void Fl_Text_Selection::update(int pos, int nDeleted, @@ -2272,7 +2272,7 @@ void Fl_Text_Selection::update(int pos, int nDeleted,
count lines quickly, hence searching for a single character: newline)
*/
int Fl_Text_Buffer::findchar_forward(int startPos, char searchChar,
int *foundPos) {
int *foundPos) const {
int pos, gapLen = mGapEnd - mGapStart;
if (startPos < 0 || startPos >= mLength) {
@ -2308,7 +2308,7 @@ int Fl_Text_Buffer::findchar_forward(int startPos, char searchChar, @@ -2308,7 +2308,7 @@ int Fl_Text_Buffer::findchar_forward(int startPos, char searchChar,
count lines quickly, hence searching for a single character: newline)
*/
int Fl_Text_Buffer::findchar_backward(int startPos, char searchChar,
int *foundPos) {
int *foundPos) const{
int pos, gapLen = mGapEnd - mGapStart;
if (startPos <= 0 || startPos > mLength) {

Loading…
Cancel
Save