public void UpdateCaretPosition()
{
if (textArea.MotherTextAreaControl.TextEditorProperties.LineViewerStyle == LineViewerStyle.FullRow && oldLine != line)
{
textArea.UpdateLine(oldLine);
textArea.UpdateLine(line);
}
oldLine = line;
if (hidden || textArea.MotherTextEditorControl.IsUpdating)
{
return;
}
try {
if (!caretCreated)
{
CreateCaret();
}
if (caretCreated)
{
ValidateCaretPos();
int lineNr = this.line;
int xpos = textArea.TextView.GetDrawingXPos(lineNr, this.column);
//LineSegment lineSegment = textArea.Document.GetLineSegment(lineNr);
Point pos = ScreenPosition;
if (xpos >= 0)
{
bool success = SetCaretPos(pos.X, pos.Y);
if (!success)
{
DestroyCaret();
caretCreated = false;
UpdateCaretPosition();
}
}
// set the input method editor location
if (ime == null)
{
ime = new Ime(textArea.Handle, textArea.Document.TextEditorProperties.Font);
}
else
{
ime.Font = textArea.Document.TextEditorProperties.Font;
}
ime.SetIMEWindowLocation(pos.X + 2,
pos.Y);
currentPos = pos;
}
} catch (Exception e) {
Console.WriteLine("Got exception while update caret position : " + e);
}
}