59,6 → 59,7 |
private ArrayList lineFragments = new ArrayList(); |
private int lastLineLen = 0; |
private int linesCount = 0; |
private int linesCountToDisplay = 0; |
private int maxLineLength = 0; |
|
private int curLine = 0; |
139,7 → 140,6 |
wordWrap = value; |
RecalcParams(); |
Invalidate(); |
// FIXME recalc number of lines for the vertical scroll bar |
} |
} |
|
152,6 → 152,7 |
validMarkers = new ArrayList(); |
lastLineLen = 0; |
linesCount = 0; |
linesCountToDisplay = 0; |
maxLineLength = 0; |
curLine = 0; |
curCol = 0; |
164,14 → 165,19 |
selEndLineOrig = -1; |
selEndPosOrig = -1; |
|
UpdateDisplayArea(); |
} |
} |
|
private void UpdateDisplayArea() |
{ |
if(!updateBlocked) |
{ |
vScrollBar.Update(curLine, 0, linesCount, 1, 1); |
vScrollBar.Update(curLine, 0, linesCountToDisplay, 1, 1); |
UpdateHScrollBar(); |
Invalidate(); |
} |
} |
} |
|
private void UpdateHScrollBar() |
{ |
218,9 → 224,12 |
|
lock(this) |
{ |
BeginUpdate(); |
|
lineBackColors = s.lineBackColors; |
lineFragments = s.lineFragments; |
linesCount = lineFragments.Count; |
RecalcLinesCountToDisplay(); |
|
validMarkers = s.validMarkers; |
|
257,11 → 266,7 |
} |
|
UpdateSelection(); |
updateBlocked = false; |
|
vScrollBar.Update(curLine, 0, linesCount, 1, linesVisible); |
UpdateHScrollBar(); |
Invalidate(); |
EndUpdateInternal(); |
} |
} |
|
300,14 → 305,16 |
{ |
lock(this) |
{ |
updateBlocked = false; |
|
vScrollBar.Update(curLine, 0, linesCount, 1, linesVisible); |
UpdateHScrollBar(); |
Invalidate(); |
EndUpdateInternal(); |
} |
} |
|
public void EndUpdateInternal() |
{ |
updateBlocked = false; |
UpdateDisplayArea(); |
} |
|
public void AppendText(string text) |
{ |
lock(this) |
386,6 → 393,9 |
{ |
lineLength += lastLine[i].indent + (lastLine[i].text == null ? 0 : lastLine[i].text.Length); |
} |
if(wordWrap && lineLength > 0) { |
linesCountToDisplay += (lineLength - 1) / GetVisibleLength(); |
} |
if(lineLength > maxLineLength) |
{ |
maxLineLength = lineLength; |
394,10 → 404,16 |
|
if(!updateBlocked) |
{ |
vScrollBar.Maximum = linesCountToDisplay; |
if(curLine + linesVisible + 1 >= lastLineLen) Invalidate(); |
} |
} |
|
private int GetVisibleLength() |
{ |
return (colsVisible - 2); |
} |
|
public void AppendNewLine() |
{ |
AppendNewLine(Color.Transparent); |
608,6 → 624,9 |
{ |
lineLength += line[i].indent + (line[i].text == null ? 0 : line[i].text.Length); |
} |
if(wordWrap && lineLength > 0) { |
linesCountToDisplay += (lineLength - 1) / GetVisibleLength(); |
} |
if(lineLength > maxLineLength) |
{ |
maxLineLength = lineLength; |
617,6 → 636,7 |
// update screen |
if(!updateBlocked) |
{ |
vScrollBar.Maximum = linesCountToDisplay; |
if(m.endLine >= curLine && m.endLine <= curLine + linesVisible + 1) Invalidate(); |
} |
|
659,6 → 679,7 |
|
if(m.endLine == linesCount - 1) lastLineLen = oldLineLen - m.endPos; |
linesCount++; |
linesCountToDisplay++; |
} |
|
// update screen |
665,7 → 686,7 |
if(!updateBlocked) |
{ |
if(m.endLine >= curLine && m.endLine <= curLine + linesVisible + 1) Invalidate(); |
vScrollBar.Maximum = linesCount; |
vScrollBar.Maximum = linesCountToDisplay; |
} |
|
ShiftTextMarkers(m.endLine, m.endPos, 1, 0); |
673,6 → 694,25 |
} |
} |
|
private void RecalcLinesCountToDisplay() |
{ |
if(wordWrap) { |
linesCountToDisplay = 0; |
|
int visibleLen = GetVisibleLength(); |
foreach(LineFragment[] line in lineFragments) { |
int lineLength = 0; |
foreach(LineFragment fragment in line) { |
lineLength += fragment.indent + (fragment.text == null ? 0 : fragment.text.Length); |
} |
linesCountToDisplay += (lineLength - 1) / visibleLen + 1; |
} |
} |
else { |
linesCountToDisplay = linesCount; |
} |
} |
|
private void ShiftTextMarkers(int line, int pos, int lineDelta, int posDelta) |
{ |
for(int i = validMarkers.Count-1; i >= 0; i--) |
739,8 → 779,9 |
lineFragments.Add(lastLine); |
|
linesCount++; |
linesCountToDisplay++; |
|
if(!updateBlocked) vScrollBar.Maximum = linesCount; |
if(!updateBlocked) vScrollBar.Maximum = linesCountToDisplay; |
|
return lastLine; |
} |
774,9 → 815,14 |
{ |
fontHeight = this.Font.GetHeight(); |
linesVisible = (fontHeight > 0) ? (int)Math.Ceiling(this.ClientSize.Height / fontHeight) : 0; |
|
RecalcColsVisible(); |
RecalcLinesCountToDisplay(); |
|
vScrollBar.LargeChange = linesVisible; |
vScrollBar.Maximum = linesCountToDisplay; |
|
RecalcColsVisible(); |
UpdateHScrollBar(); |
} |
|
private void UpdateFontWidth(Graphics g) |
783,12 → 829,14 |
{ |
fontWidth = g.MeasureString("x", this.Font, int.MaxValue, fontMeasureFormat).Width; |
RecalcColsVisible(); |
RecalcLinesCountToDisplay(); |
|
UpdateHScrollBar(); |
} |
|
private void RecalcColsVisible() |
{ |
colsVisible = (fontWidth > 0) ? (int)Math.Ceiling(this.ClientSize.Width / fontWidth) : 0; |
UpdateHScrollBar(); |
} |
|
protected override void OnSystemColorsChanged(EventArgs e) |
890,7 → 938,7 |
// FIXME test if wrap is in fragment indent |
if(wordWrap) |
{ |
int visibleLen = colsVisible - 2; |
int visibleLen = GetVisibleLength(); |
int availableLen = visibleLen - indent - curIndent; |
if(textLen > availableLen) |
{ |
1121,7 → 1169,7 |
private void MoveToVertical(int pos, bool invalidate) |
{ |
curLine = pos; |
if(curLine + linesVisible > linesCount) curLine = linesCount - linesVisible + 1; |
if(curLine + linesVisible > linesCountToDisplay) curLine = linesCountToDisplay - linesVisible + 1; |
if(curLine < 0) curLine = 0; |
vScrollBar.Value = curLine; |
if(invalidate) this.Invalidate(); |
1229,7 → 1277,7 |
lock(this) |
{ |
MoveToHorizontal(0, false); |
MoveToVertical(linesCount - linesVisible + 1, true); |
MoveToVertical(linesCountToDisplay - linesVisible + 1, true); |
} |
break; |
|