// TBWidgetListener virtual bool OnWidgetInvokeEvent(TBWidget *widget, const TBWidgetEvent &ev) { // Skip these events for now if (ev.IsPointerEvent()) return false; // Always ignore activity in this window (or we might get endless recursion) if (TBWindow *window = widget->GetParentWindow()) if (TBSafeCast<DebugSettingsWindow>(window)) return false; TBTempBuffer buf; buf.AppendString(GetEventTypeStr(ev.type)); buf.AppendString(" ("); buf.AppendString(widget->GetClassName()); buf.AppendString(")"); buf.AppendString(" id: "); buf.AppendString(GetIDString(ev.target->GetID())); if (ev.ref_id) { buf.AppendString(", ref_id: "); buf.AppendString(GetIDString(ev.ref_id)); } if (ev.type == EVENT_TYPE_CHANGED) { TBStr extra, text; if (ev.target->GetText(text) && text.Length() > 24) sprintf(text.CStr() + 20, "..."); extra.SetFormatted(", value: %.2f (\"%s\")", ev.target->GetValueDouble(), text.CStr()); buf.AppendString(extra); } buf.AppendString("\n"); // Append the line to the output textfield TBStyleEdit *se = output->GetStyleEdit(); se->selection.SelectNothing(); se->AppendText(buf.GetData(), TB_ALL_TO_TERMINATION, true); se->ScrollIfNeeded(false, true); // Remove lines from the top if we exceed the height limit. const int height_limit = 2000; int current_height = se->GetContentHeight(); if (current_height > height_limit) { se->caret.Place(TBPoint(0, current_height - height_limit)); se->selection.SelectToCaret(se->blocks.GetFirst(), 0); se->Delete(); } return false; }
static bool GetTextPairs(const UString &srcString, CObjectVector<CTextPair> &pairs) { pairs.Clear(); unsigned pos = 0; if (srcString.Len() > 0) { if (srcString[0] == kBOM) pos++; } while (pos < srcString.Len()) { unsigned finishPos; UString id = GetIDString((const wchar_t *)srcString + pos, finishPos); pos += finishPos; if (id.IsEmpty()) continue; UString value = GetValueString((const wchar_t *)srcString + pos, finishPos); pos += finishPos; if (!id.IsEmpty()) { CTextPair pair; pair.ID = id; pair.Value = value; pairs.Add(pair); } } return true; }
bool GetTextConfig(const AString &s, CObjectVector<CTextConfigPair> &pairs) { pairs.Clear(); unsigned pos = 0; ///////////////////// // read strings for (;;) { if (!SkipSpaces(s, pos)) break; CTextConfigPair pair; unsigned finishPos; AString temp = GetIDString(((const char *)s) + pos, finishPos); if (!ConvertUTF8ToUnicode(temp, pair.ID)) return false; if (finishPos == 0) return false; pos += finishPos; if (!SkipSpaces(s, pos)) return false; if (s[pos] != '=') return false; pos++; if (!SkipSpaces(s, pos)) return false; if (s[pos] != '\"') return false; pos++; AString message; for (;;) { if (pos >= s.Len()) return false; char c = s[pos++]; if (c == '\"') break; if (c == '\\') { c = s[pos++]; switch (c) { case 'n': message += '\n'; break; case 't': message += '\t'; break; case '\\': message += '\\'; break; case '\"': message += '\"'; break; default: message += '\\'; message += c; break; } } else message += c; } if (!ConvertUTF8ToUnicode(message, pair.String)) return false; pairs.Add(pair); } return true; }