Holy Gucamole! NEdit was designed with 'C' style strings in mind. Until that is that someone had the great idea to allow <nul> as a valid character in the text editor. The developers jumped through quite some hoops to allow that without rewriting the core. Well, actually they did: they added a parameter to pretty much every internal call that conatined the null-replacement-character. Anyway, since we only handle 'C' strings, I remove all related code.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7437 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2010-04-05 20:22:43 +00:00
parent d5175c0b88
commit fca1c022e7
3 changed files with 432 additions and 607 deletions

View File

@ -668,8 +668,7 @@ public:
\p nulSubsChar represent the null character to be transformed in \<nul\>
\todo unicode check
*/
static int expand_character(char c, int indent, char* outStr, int tabDist,
char nullSubsChar);
static int expand_character(char c, int indent, char* outStr, int tabDist);
/**
Return the length in displayed characters of character \p c expanded
@ -679,7 +678,7 @@ public:
to ignore).
\todo unicode check
*/
static int character_width(char c, int indent, int tabDist, char nullSubsChar);
static int character_width(char c, int indent, int tabDist);
/**
Count the number of displayed characters between buffer position
@ -779,33 +778,6 @@ public:
int search_backward(int startPos, const char* searchString, int* foundPos,
int matchCase = 0) const;
/**
The primary routine for integrating new text into a text buffer with
substitution of another character for ascii nuls. This substitutes null
characters in the string in preparation for being copied or replaced
into the buffer, and if necessary, adjusts the buffer as well, in the
event that the string contains the character it is currently using for
substitution. Returns 0, if substitution is no longer possible
because all non-printable characters are already in use.
\todo unicode check
*/
int substitute_null_characters(char* string, int length);
/**
Converts strings obtained from buffers which contain null characters, which
have been substituted for by a special substitution character, back to
a null-containing string. There is no time penalty for calling this
routine if no substitution has been done.
\todo unicode check
*/
void unsubstitute_null_characters(char* string);
/**
Returns the current nul substitution character.
\todo unicode check
*/
char null_substitution_character() const { return mNullSubsChar; }
/**
Returns the primary selection.
\todo unicode check
@ -985,11 +957,6 @@ protected:
void **mPredeleteCbArgs; /**< caller argument for pre-delete proc above */
int mCursorPosHint; /**< hint for reasonable cursor position after
a buffer modification operation */
char mNullSubsChar; /**< NEdit is based on C null-terminated strings,
so ascii-nul characters must be substituted
with something else. This is the else, but
of course, things get quite messy when you
use it */
char mCanUndo; /**< if this buffer is used for attributes, it must
not do any undo calls */
int mPreferredGapSize; /**< the default allocation for the text gap is 1024

File diff suppressed because it is too large Load Diff

View File

@ -629,7 +629,7 @@ void Fl_Text_Display::overstrike(const char* text) {
startIndent = mBuffer->count_displayed_characters( lineStart, startPos );
indent = startIndent;
for ( c = text; *c != '\0'; c++ )
indent += Fl_Text_Buffer::character_width( *c, indent, buf->tab_distance(), buf->null_substitution_character() );
indent += Fl_Text_Buffer::character_width( *c, indent, buf->tab_distance() );
endIndent = indent;
/* find which characters to remove, and if necessary generate additional
@ -641,7 +641,7 @@ void Fl_Text_Display::overstrike(const char* text) {
ch = buf->character( p );
if ( ch == '\n' )
break;
indent += Fl_Text_Buffer::character_width( ch, indent, buf->tab_distance(), buf->null_substitution_character() );
indent += Fl_Text_Buffer::character_width( ch, indent, buf->tab_distance() );
if ( indent == endIndent ) {
p++;
break;
@ -724,7 +724,7 @@ int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const {
outIndex = 0;
for ( charIndex = 0; charIndex < lineLen && charIndex < pos - lineStartPos; charIndex++ ) {
charLen = Fl_Text_Buffer::expand_character( lineStr[ charIndex ], outIndex, expandedChar,
mBuffer->tab_distance(), mBuffer->null_substitution_character() );
mBuffer->tab_distance());
if (charLen > 1 && (lineStr[ charIndex ] & 0x80)) {
int i, ii = 0;;
i = fl_utf8len(lineStr[ charIndex ]);
@ -1478,7 +1478,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
for ( charIndex = 0; ; charIndex++ ) {
charLen = charIndex >= lineLen ? 1 :
Fl_Text_Buffer::expand_character( lineStr[ charIndex ], outIndex,
expandedChar, buf->tab_distance(), buf->null_substitution_character() );
expandedChar, buf->tab_distance());
if (charIndex < lineLen && charLen > 1 && (lineStr[ charIndex ] & 0x80)) {
int i, ii = 0;;
i = fl_utf8len(lineStr[ charIndex ]);
@ -1516,7 +1516,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
for ( charIndex = startIndex; charIndex < rightCharIndex; charIndex++ ) {
charLen = charIndex >= lineLen ? 1 :
Fl_Text_Buffer::expand_character( lineStr[ charIndex ], outIndex, expandedChar,
buf->tab_distance(), buf->null_substitution_character() );
buf->tab_distance());
if (charIndex < lineLen && charLen > 1 && (lineStr[ charIndex ] & 0x80)) {
int i, ii = 0;;
i = fl_utf8len(lineStr[ charIndex ]);
@ -1563,7 +1563,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
for ( charIndex = startIndex; charIndex < rightCharIndex; charIndex++ ) {
charLen = charIndex >= lineLen ? 1 :
Fl_Text_Buffer::expand_character( lineStr[ charIndex ], outIndex, expandedChar,
buf->tab_distance(), buf->null_substitution_character() );
buf->tab_distance());
if (charIndex < lineLen && charLen > 1 && (lineStr[ charIndex ] & 0x80)) {
int i, ii = 0;;
i = fl_utf8len(lineStr[ charIndex ]);
@ -1923,7 +1923,7 @@ int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
outIndex = 0;
for ( charIndex = 0; charIndex < lineLen; charIndex++ ) {
charLen = Fl_Text_Buffer::expand_character( lineStr[ charIndex ], outIndex, expandedChar,
mBuffer->tab_distance(), mBuffer->null_substitution_character() );
mBuffer->tab_distance());
if (charLen > 1 && (lineStr[ charIndex ] & 0x80)) {
int i, ii = 0;;
i = fl_utf8len(lineStr[ charIndex ]);
@ -2676,7 +2676,6 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
bool countPixels;
int nLines = 0, tabDist = buffer()->tab_distance();
unsigned char c;
char nullSubsChar = buffer()->null_substitution_character();
/* If the font is fixed, or there's a wrap margin set, it's more efficient
to measure in columns, than to count pixels. Determine if we can count
@ -2731,7 +2730,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
colNum = 0;
width = 0;
} else {
colNum += Fl_Text_Buffer::character_width(c, colNum, tabDist, nullSubsChar);
colNum += Fl_Text_Buffer::character_width(c, colNum, tabDist);
if (countPixels)
width += measure_proportional_character(c, colNum, p+styleBufOffset);
}
@ -2761,7 +2760,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
}
if (!foundBreak) { /* no whitespace, just break at margin */
newLineStart = max(p, lineStart+1);
colNum = Fl_Text_Buffer::character_width(c, colNum, tabDist, nullSubsChar);
colNum = Fl_Text_Buffer::character_width(c, colNum, tabDist);
if (countPixels)
width = measure_proportional_character(c, colNum, p+styleBufOffset);
}
@ -2813,8 +2812,7 @@ int Fl_Text_Display::measure_proportional_character(char c, int colNum, int pos)
char expChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
Fl_Text_Buffer *styleBuf = mStyleBuffer;
charLen = Fl_Text_Buffer::expand_character(c, colNum, expChar,
buffer()->tab_distance(), buffer()->null_substitution_character());
charLen = Fl_Text_Buffer::expand_character(c, colNum, expChar, buffer()->tab_distance());
if (styleBuf == 0) {
style = 0;
} else {