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 /// system timer interval expired - notify queue
protected void onTimer() { protected void onTimer() {
//Log.d("window.onTimer");
bool res = _timerQueue.notify(); bool res = _timerQueue.notify();
//Log.d("window.onTimer after notify");
if (res) { if (res) {
// check if update needed and redraw if so // check if update needed and redraw if so
//Log.d("before update");
update(false); update(false);
//Log.d("after update");
} }
//Log.d("schedule next timer");
long nextInterval = _timerQueue.nextIntervalMillis(); long nextInterval = _timerQueue.nextIntervalMillis();
if (nextInterval > 0) { if (nextInterval > 0) {
scheduleSystemTimer(nextInterval); scheduleSystemTimer(nextInterval);
} }
//Log.d("schedule next timer done");
} }
/// set timer for destination widget - destination.onTimer() will be called after interval expiration; returns timer id /// 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 long _nextExpectedTimerTs;
private UINT_PTR _timerId; private UINT_PTR _timerId = 1;
/// schedule timer for interval in milliseconds - call window.onTimer when finished /// schedule timer for interval in milliseconds - call window.onTimer when finished
override protected void scheduleSystemTimer(long intervalMillis) { override protected void scheduleSystemTimer(long intervalMillis) {
@ -329,14 +329,21 @@ class Win32Window : Window {
if (_timerId && _nextExpectedTimerTs && _nextExpectedTimerTs < nextts + 10) if (_timerId && _nextExpectedTimerTs && _nextExpectedTimerTs < nextts + 10)
return; // don't reschedule timer, timer event will be received soon return; // don't reschedule timer, timer event will be received soon
if (_hwnd) { if (_hwnd) {
_timerId = SetTimer(_hwnd, _timerId, cast(uint)intervalMillis, null); //_timerId =
SetTimer(_hwnd, _timerId, cast(uint)intervalMillis, null);
_nextExpectedTimerTs = nextts; _nextExpectedTimerTs = nextts;
} }
} }
void handleTimer(UINT_PTR timerId) { void handleTimer(UINT_PTR timerId) {
//Log.d("handleTimer id=", timerId);
if (timerId == _timerId) {
KillTimer(_hwnd, timerId);
//_timerId = 0;
_nextExpectedTimerTs = 0;
onTimer(); onTimer();
} }
}
Win32ColorDrawBuf getDrawBuf() { Win32ColorDrawBuf getDrawBuf() {

View File

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