fix win32 platform timers; fix crash in editors; improve logger widget

This commit is contained in:
Vadim Lopatin 2015-01-28 23:05:15 +03:00
parent 4920646aa8
commit 0ef9a43d1a
3 changed files with 29 additions and 6 deletions

View File

@ -849,15 +849,21 @@ class Window {
/// system timer interval expired - notify queue
protected void onTimer() {
//Log.d("window.onTimer");
bool res = _timerQueue.notify();
//Log.d("window.onTimer after notify");
if (res) {
// check if update needed and redraw if so
//Log.d("before update");
update(false);
//Log.d("after update");
}
//Log.d("schedule next timer");
long nextInterval = _timerQueue.nextIntervalMillis();
if (nextInterval > 0) {
scheduleSystemTimer(nextInterval);
}
//Log.d("schedule next timer done");
}
/// set timer for destination widget - destination.onTimer() will be called after interval expiration; returns timer id

View File

@ -319,7 +319,7 @@ class Win32Window : Window {
}
private long _nextExpectedTimerTs;
private UINT_PTR _timerId;
private UINT_PTR _timerId = 1;
/// schedule timer for interval in milliseconds - call window.onTimer when finished
override protected void scheduleSystemTimer(long intervalMillis) {
@ -329,13 +329,20 @@ class Win32Window : Window {
if (_timerId && _nextExpectedTimerTs && _nextExpectedTimerTs < nextts + 10)
return; // don't reschedule timer, timer event will be received soon
if (_hwnd) {
_timerId = SetTimer(_hwnd, _timerId, cast(uint)intervalMillis, null);
//_timerId =
SetTimer(_hwnd, _timerId, cast(uint)intervalMillis, null);
_nextExpectedTimerTs = nextts;
}
}
void handleTimer(UINT_PTR timerId) {
onTimer();
//Log.d("handleTimer id=", timerId);
if (timerId == _timerId) {
KillTimer(_hwnd, timerId);
//_timerId = 0;
_nextExpectedTimerTs = 0;
onTimer();
}
}

View File

@ -681,7 +681,8 @@ class EditableContent {
// update highlight if necessary
updateTokenProps(rangeAfter.start.line, rangeAfter.end.line + 1);
// call listeners
contentChangeListeners(this, op, rangeBefore, rangeAfter, source);
if (contentChangeListeners.assigned)
contentChangeListeners(this, op, rangeBefore, rangeAfter, source);
}
/// return text for specified range
@ -2405,6 +2406,13 @@ class EditBox : EditWidgetBase {
FontRef font = font();
_lineHeight = font.height;
_numVisibleLines = (_clientRect.height + _lineHeight - 1) / _lineHeight;
if (_firstVisibleLine >= _content.length) {
_firstVisibleLine = _content.length - _numVisibleLines + 1;
if (_firstVisibleLine < 0)
_firstVisibleLine = 0;
_caretPos.line = _content.length - 1;
_caretPos.pos = 0;
}
if (_firstVisibleLine + _numVisibleLines > _content.length)
_numVisibleLines = _content.length - _firstVisibleLine;
_visibleLines.length = _numVisibleLines;
@ -2942,13 +2950,15 @@ class LogWidget : EditBox {
super(ID);
_scrollLock = true;
enabled = false;
fontSize = 12;
fontSize = 15;
fontFace = "Consolas,Lucida Console,Courier New";
fontFamily = FontFamily.MonoSpace;
}
/// append lines to the end of text
void appendLines(dstring[] lines...) {
lines ~= ""d; // append new line after last line
if (lines.length == 0)
return;
//lines ~= ""d; // append new line after last line
content.appendLines(lines);
if (_maxLines > 0 && lineCount > _maxLines) {
TextRange range;