Don't draw control chars in MMTextStorage

It can happen that MMTextStorage is asked to draw characters from the
"Control Characters" set (e.g. when :shell is invoked).  This would
cause internal errors in MMTextStorage so when control chars are
detected, simply draw blanks instead.
This commit is contained in:
Bjorn Winckler
2008-06-06 14:24:49 +02:00
parent 3915c6afc6
commit 9c517cb4e9
+10
View File
@@ -258,6 +258,16 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
|| col+cells > maxColumns || !string || !(fg && bg && sp))
return;
BOOL hasControlChars = [string rangeOfCharacterFromSet:
[NSCharacterSet controlCharacterSet]].location != NSNotFound;
if (hasControlChars) {
// HACK! If a string for some reason contains control characters, then
// draw blanks instead (otherwise charRangeForRow::: fails).
NSRange subRange = { 0, cells };
flags &= ~DRAW_WIDE;
string = [[emptyRowString string] substringWithRange:subRange];
}
// Find range of characters in text storage to replace.
int acol = col;
int acells = cells;