mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-26 14:23:08 -06:00
Developing T++
git-svn-id: svn://ultimatepp.org/upp/trunk@569 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
8d94d21ee8
commit
a1971753be
13 changed files with 92 additions and 58 deletions
|
|
@ -31,9 +31,19 @@ oid]_[* IterSwap]([*@4 I]_[*@3 a], [*@4 I]_[*@3 b])&]
|
|||
[s6; Swap must be defined for type pointed to by I.&]
|
||||
[s7; [*C@4 I]-|Iterator type.&]
|
||||
[s7; [*C@3 a]-|Iterator pointing to first value.&]
|
||||
[s7; [*C@3 b]-|Iterator pointing to second value.&]
|
||||
[s3;%- &]
|
||||
[s7; [*C@3 b]-|Iterator pointing to second value. xx&]
|
||||
[s3;%- yy&]
|
||||
[s4;%- &]
|
||||
[s5;:IterSwap`(I`,I`):%- [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 I][@(0.0.255) >]_[@(0.0.255) v
|
||||
oid]_[* IterSwap]([*@4 I]_[*@3 a], [*@4 I]_[*@3 b])&]
|
||||
[s2; Swaps values pointed to by iterators. Specific types might specialize
|
||||
[* IterSwap] with more effective variants.&]
|
||||
[s6; Swap must be defined for type pointed to by I.&]
|
||||
[s7; [*C@4 I]-|Iterator type.&]
|
||||
[s7; [*C@3 a]-|Iterator pointing to first value.&]
|
||||
[s7; [*C@3 b]-|Iterator pointing to second value. xx&]
|
||||
[s3;%- yy&]
|
||||
[s0; &]
|
||||
[s5;:FindLowerBound`(const C`&`,int`,int`,const T`&`,const L`&`):%- [@(0.0.255) templat
|
||||
e]_<[@(0.0.255) class]_[*@4 C], [@(0.0.255) class]_[*@4 T], [@(0.0.255) class]_[*@4 L][@(0.0.255) >
|
||||
]_[@(0.0.255) int]_[* FindLowerBound]([@(0.0.255) const]_[*@4 C][@(0.0.255) `&]_[*@3 v],
|
||||
|
|
|
|||
|
|
@ -1040,6 +1040,9 @@ public:
|
|||
void RefreshLayout() { SyncLayout(1); }
|
||||
void RefreshLayoutDeep() { SyncLayout(2); }
|
||||
void RefreshParentLayout() { if(parent) parent->RefreshLayout(); }
|
||||
|
||||
void UpdateLayout() { SyncLayout(); }
|
||||
void UpdateParentLayout() { if(parent) parent->UpdateLayout(); }
|
||||
|
||||
Ctrl& LeftPos(int a, int size = STDSIZE);
|
||||
Ctrl& RightPos(int a, int size = STDSIZE);
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ BarCtrl& BarCtrl::Align(int al) {
|
|||
void BarCtrl::SyncBar()
|
||||
{
|
||||
if(IsChild() && InFrame())
|
||||
RefreshParentLayout();
|
||||
UpdateParentLayout();
|
||||
else
|
||||
Layout();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ void RichEdit::FinishNF()
|
|||
sb = 0;
|
||||
else
|
||||
sb.ScrollInto(r.top, r.Height());
|
||||
SetZsc();
|
||||
PageY top, bottom;
|
||||
int sell = min(cursor, anchor);
|
||||
int selh = max(cursor, anchor);
|
||||
|
|
|
|||
|
|
@ -170,6 +170,11 @@ int RichEdit::GetHotSpot(Point p) const
|
|||
return -1;
|
||||
}
|
||||
|
||||
void RichEdit::SetZsc()
|
||||
{
|
||||
zsc = (int)sb / GetZoom();
|
||||
}
|
||||
|
||||
void RichEdit::SetSb()
|
||||
{
|
||||
sb.SetTotal(GetPosY(text.GetHeight(pagesz)) + 10);
|
||||
|
|
@ -206,6 +211,7 @@ void RichEdit::Layout()
|
|||
sb.SetPage(sz.cy > 10 ? sz.cy - 4 : sz.cy);
|
||||
SetupRuler();
|
||||
SetSb();
|
||||
sb = zsc * GetZoom();
|
||||
PlaceCaret();
|
||||
if(GetSize() != p_size) {
|
||||
sizetracking = true;
|
||||
|
|
@ -378,6 +384,7 @@ void RichEdit::Clear()
|
|||
ReadStyles();
|
||||
SetModify();
|
||||
modified = true;
|
||||
zsc = 0;
|
||||
}
|
||||
|
||||
void RichEdit::SetupLanguage(pick_ Vector<int>& _lng)
|
||||
|
|
@ -513,22 +520,34 @@ void RichEdit::SetPickUndoInfo(pick_ UndoInfo& f)
|
|||
Finish();
|
||||
}
|
||||
|
||||
void RichEdit::PosInfo::Serialize(Stream& s)
|
||||
{
|
||||
int version = 1;
|
||||
s / version;
|
||||
s % cursor % anchor % zsc;
|
||||
if(version == 0)
|
||||
zsc = 0;
|
||||
}
|
||||
|
||||
RichEdit::PosInfo RichEdit::GetPosInfo() const
|
||||
{
|
||||
PosInfo f;
|
||||
f.cursor = cursor;
|
||||
f.anchor = anchor;
|
||||
f.sbpos = sb;
|
||||
f.zsc = zsc;
|
||||
return f;
|
||||
}
|
||||
|
||||
void RichEdit::SetPosInfo(const PosInfo& f)
|
||||
{
|
||||
DDUMP(f.cursor);
|
||||
int l = text.GetLength();
|
||||
cursor = min(l, f.cursor);
|
||||
anchor = min(l, f.anchor);
|
||||
sb = f.sbpos;
|
||||
DDUMP(cursor);
|
||||
Finish();
|
||||
zsc = f.zsc;
|
||||
Layout();
|
||||
}
|
||||
|
||||
void RichEdit::DoRefreshBar()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ bool RichEdit::Key(dword key, int count)
|
|||
MoveWordLeft(false);
|
||||
if(InvalidRange(cursor, c))
|
||||
return true;
|
||||
Remove(cursor, c - cursor, true);
|
||||
Remove(cursor, c - cursor);
|
||||
objectpos = -1;
|
||||
FinishNF();
|
||||
return true;
|
||||
|
|
@ -29,12 +29,12 @@ bool RichEdit::Key(dword key, int count)
|
|||
if(cursor <= 0 || RemoveSpecial(cursor, cursor - 1, true))
|
||||
return true;
|
||||
anchor = --cursor;
|
||||
Remove(cursor, 1, true);
|
||||
Remove(cursor, 1);
|
||||
break;
|
||||
case K_DELETE:
|
||||
if(RemoveSelection()) return true;
|
||||
if(cursor < text.GetLength() && !RemoveSpecial(cursor, cursor + 1, false))
|
||||
Remove(cursor, 1);
|
||||
Remove(cursor, 1, true);
|
||||
break;
|
||||
case K_INSERT:
|
||||
overwrite = !overwrite;
|
||||
|
|
|
|||
|
|
@ -71,22 +71,24 @@ void RichEdit::ModifyFormat(int pos, const RichText::FormatInfo& fi, int count)
|
|||
text.ApplyFormatInfo(pos, fi, count);
|
||||
}
|
||||
|
||||
void RichEdit::Remove(int pos, int len, bool back)
|
||||
void RichEdit::Remove(int pos, int len, bool forward)
|
||||
{
|
||||
if(IsReadOnly())
|
||||
return;
|
||||
Limit(pos, len);
|
||||
if(InvalidRange(pos, pos + len))
|
||||
return;
|
||||
if(back) {
|
||||
RichTxt::FormatInfo fi;
|
||||
if(forward)
|
||||
fi = text.GetFormatInfo(pos, 0);
|
||||
AddUndo(new UndoRemove(text, pos, len));
|
||||
text.Remove(pos, len);
|
||||
if(forward) {
|
||||
SaveFormat(pos, 0);
|
||||
RichTxt::FormatInfo fi = text.GetFormatInfo(pos + len, 0);
|
||||
text.ReplaceStyle(pos, fi.styleid);
|
||||
fi.paravalid &= ~RichText::STYLE;
|
||||
text.ApplyFormatInfo(pos, fi, 0);
|
||||
}
|
||||
AddUndo(new UndoRemove(text, pos, len));
|
||||
text.Remove(pos, len);
|
||||
SetModify();
|
||||
modified = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ private:
|
|||
int gx;
|
||||
int oselh, osell;
|
||||
int objectpos;
|
||||
int zsc;
|
||||
Rect objectrect;
|
||||
RichHotPos tabmove;
|
||||
int mpos;
|
||||
|
|
@ -354,6 +355,7 @@ private:
|
|||
int GetNearestPos(int x, PageY py);
|
||||
void SetSb();
|
||||
void Scroll();
|
||||
void SetZsc();
|
||||
Rect PlaceCaret();
|
||||
void FinishNF();
|
||||
void Finish();
|
||||
|
|
@ -420,7 +422,7 @@ private:
|
|||
static void SetupFaceList(DropList& face);
|
||||
|
||||
void Insert(int pos, const RichText& text, bool typing = false);
|
||||
void Remove(int pos, int len, bool back = false);
|
||||
void Remove(int pos, int len, bool forward = false);
|
||||
void SaveFormat(int pos, int count);
|
||||
void SaveFormat();
|
||||
void ModifyFormat(int pos, const RichText::FormatInfo& fi, int count);
|
||||
|
|
@ -664,9 +666,9 @@ public:
|
|||
struct PosInfo {
|
||||
int cursor;
|
||||
int anchor;
|
||||
int sbpos;
|
||||
int zsc;
|
||||
|
||||
void Serialize(Stream& s) { int version = 0; s / version % cursor % anchor % sbpos; }
|
||||
void Serialize(Stream& s);
|
||||
};
|
||||
|
||||
UndoInfo PickUndoInfo();
|
||||
|
|
|
|||
|
|
@ -86,14 +86,13 @@ void RichText::Remove(int pos, int count)
|
|||
txt.Put(pi, pa, style);
|
||||
}
|
||||
else {
|
||||
RichPara pa, pa2;
|
||||
pa = txt.Get(pi, style);
|
||||
pa2 = txt.Get(pi2, pa.format.styleid, style);
|
||||
RichPara pa2 = txt.Get(pi2, style);
|
||||
RichPara pa = txt.Get(pi, pa2.format.styleid, style);
|
||||
txt.part.Remove(pi, pi2 - pi);
|
||||
pa.Trim(pos);
|
||||
pa2.Mid(pos2);
|
||||
pa.Append(pa2);
|
||||
pa2.format = pa.format;
|
||||
pa.format = pa2.format;
|
||||
txt.Put(pi, pa, style);
|
||||
txt.SetRefreshFrom(pi);
|
||||
}
|
||||
|
|
@ -111,16 +110,17 @@ void RichText::Insert(int pos, const RichText& p)
|
|||
if(n) {
|
||||
txt.part.Insert(pi + 1, p.part, 1, n);
|
||||
RichPara pa1, pa2;
|
||||
pa2 = txt.Get(pi + n, style);
|
||||
pa1 = txt.Get(pi, pa2.format.styleid, style);
|
||||
pa1 = txt.Get(pi, style);
|
||||
pa2 = txt.Get(pi + n, pa1.format.styleid, style);
|
||||
pa1.Mid(pos);
|
||||
pa2.Append(pa1);
|
||||
pa2.format = pa1.format;
|
||||
txt.Put(pi + n, pa2, style);
|
||||
pa1 = txt.Get(pi, style);
|
||||
pa2 = p.RichTxt::Get(0, GetStyle(pa1.format.styleid));
|
||||
pa2 = p.RichTxt::Get(0, p.GetStyle(p.GetParaStyle(0)));
|
||||
pa1 = txt.Get(pi, pa2.format.styleid, style);
|
||||
pa1.Trim(pos);
|
||||
pa1.Append(pa2);
|
||||
pa2.format = pa1.format;
|
||||
pa1.format = pa2.format;
|
||||
txt.Put(pi, pa1, style);
|
||||
txt.SetRefreshFrom(pi);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ String HttpClient::Execute(Gate2<int, int> progress)
|
|||
LLOG("request: " << request);
|
||||
int written = 0;
|
||||
while(msecs() < end_time) {
|
||||
int nwrite = socket.WriteWait(request.GetIter(written), request.GetLength() - written, 1000);
|
||||
int nwrite = socket.WriteWait(request.GetIter(written), min(request.GetLength() - written, 1000), 1000);
|
||||
if(socket.IsError()) {
|
||||
error = Socket::GetErrorText();
|
||||
return String::GetVoid();
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ protected:
|
|||
|
||||
void Tools(Bar& bar);
|
||||
void Label(String&);
|
||||
void CreateQtf(const String& item, const String& name, const CppItem& m, String& p1, String& p2);
|
||||
String CreateQtf(const String& item, const String& name, const CppItem& m, bool onlyhdr = false);
|
||||
void InsertItem();
|
||||
|
||||
void FindBrokenRef();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ Uuid BeginUuid()
|
|||
|
||||
Uuid EndUuid()
|
||||
{
|
||||
return ScanUuid(ENDSTYLE);
|
||||
static Uuid u = ScanUuid(ENDSTYLE);
|
||||
return u;
|
||||
}
|
||||
|
||||
void TopicEditor::FindBrokenRef()
|
||||
|
|
@ -212,8 +213,7 @@ String DecoratedItem(const String& name, const CppItem& m, const char *natural)
|
|||
return qtf + "]";
|
||||
}
|
||||
|
||||
void TopicEditor::CreateQtf(const String& item, const String& name, const CppItem& m,
|
||||
String& p1, String& p2)
|
||||
String TopicEditor::CreateQtf(const String& item, const String& name, const CppItem& m, bool onlyhdr)
|
||||
{
|
||||
String qtf;
|
||||
bool str = m.kind == STRUCT || m.kind == STRUCTTEMPLATE;
|
||||
|
|
@ -247,8 +247,8 @@ void TopicEditor::CreateQtf(const String& item, const String& name, const CppIte
|
|||
qtf << k << DecoratedItem(name, m, m.natural);
|
||||
|
||||
qtf << "&]";
|
||||
p1 = qtf;
|
||||
qtf.Clear();
|
||||
if(onlyhdr)
|
||||
return qtf;
|
||||
qtf << "[s3%% ";
|
||||
String d;
|
||||
Vector<String> t = Split(m.tname, ';');
|
||||
|
|
@ -268,8 +268,7 @@ void TopicEditor::CreateQtf(const String& item, const String& name, const CppIte
|
|||
qtf << d << '.';
|
||||
qtf << "&]";
|
||||
qtf << "[s7 &]";
|
||||
p2 = qtf;
|
||||
return;
|
||||
return qtf;
|
||||
}
|
||||
|
||||
void TopicEditor::InsertItem()
|
||||
|
|
@ -301,31 +300,25 @@ void TopicEditor::InsertItem()
|
|||
editor.PasteText(ParseQTF(qtf));
|
||||
return;
|
||||
}
|
||||
String p1, p2;
|
||||
String qtf;
|
||||
if(ref.item.IsSelection()) {
|
||||
for(int i = 0; i < ref.item.GetCount(); i++)
|
||||
if(ref.item.IsSelected(i)) {
|
||||
String a1, a2;
|
||||
const CppItemInfo& m = ref.GetItemInfo(i);
|
||||
CreateQtf(ref.GetCodeRef(i), m.name, m, a1, a2);
|
||||
p1 << p2 << a1;
|
||||
p2 = a2;
|
||||
qtf << CreateQtf(ref.GetCodeRef(i), m.name, m);
|
||||
}
|
||||
}
|
||||
else
|
||||
if(ref.item.IsCursor()) {
|
||||
const CppItemInfo& m = ref.GetItemInfo();
|
||||
CreateQtf(ref.GetCodeRef(), m.name, m, p1, p2);
|
||||
qtf << CreateQtf(ref.GetCodeRef(), m.name, m);
|
||||
}
|
||||
else
|
||||
return;
|
||||
editor.BeginOp();
|
||||
int a = editor.GetCursor();
|
||||
editor.PasteText(ParseQTF(styles + p1));
|
||||
c = editor.GetCursor();
|
||||
editor.PasteText(ParseQTF(styles + p2));
|
||||
editor.Move(a);
|
||||
editor.Move(c);
|
||||
editor.PasteText(ParseQTF(styles + qtf));
|
||||
editor.PrevPara();
|
||||
editor.PrevPara();
|
||||
}
|
||||
|
||||
void TopicEditor::GoTo(const String& _topic, const String& link, const String& create)
|
||||
|
|
@ -334,18 +327,23 @@ void TopicEditor::GoTo(const String& _topic, const String& link, const String& c
|
|||
editor.Select(editor.GetLength(), 0);
|
||||
editor.GotoLabel(link);
|
||||
if(!IsNull(create)) {
|
||||
for(bool firstpass = true; firstpass; firstpass = false)
|
||||
for(;;) {
|
||||
int c = editor.GetCursor();
|
||||
RichText::FormatInfo f = editor.GetFormatInfo();
|
||||
if(f.styleid == BeginUuid() || (IsNull(f.label) || f.label == "noref") == firstpass)
|
||||
break;
|
||||
editor.NextPara();
|
||||
if(editor.GetCursor() == c)
|
||||
break;
|
||||
}
|
||||
String p1, p2;
|
||||
const CppItem *m = GetCodeRefItem(create);
|
||||
if(!m)
|
||||
return;
|
||||
CreateQtf(link, m->name, *m, p1, p2);
|
||||
editor.BeginOp();
|
||||
int a = editor.GetCursor();
|
||||
editor.PasteText(ParseQTF(styles + p1));
|
||||
int c = editor.GetCursor();
|
||||
editor.PasteText(ParseQTF(styles + p2));
|
||||
editor.Move(a);
|
||||
editor.Move(c);
|
||||
editor.PasteText(ParseQTF(styles + CreateQtf(link, m->name, *m)));
|
||||
editor.PrevPara();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -407,10 +405,7 @@ void TopicEditor::FixTopic()
|
|||
if(q >= 0) {
|
||||
started = true;
|
||||
const CppItem& m = n[q];
|
||||
String p1, p2;
|
||||
CreateQtf(link[q], n[q].name, m, p1, p2);
|
||||
p1 = "[s7; &]" + p1;
|
||||
RichText h = ParseQTF(styles + p1);
|
||||
RichText h = ParseQTF(styles + ("&[s7; &]" + CreateQtf(link[q], n[q].name, m, true)));
|
||||
if(h.GetPartCount())
|
||||
h.RemovePart(h.GetPartCount() - 1);
|
||||
result.CatPick(h);
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ void TopicEditor::Load(const String& fn)
|
|||
if(fi.time == FileGetTime(fn)) {
|
||||
editor.SetPickUndoInfo(fi.undo);
|
||||
fi.time = Time(1, 1, 1);
|
||||
editor.SetPosInfo(fi.pos);
|
||||
}
|
||||
editor.SetPosInfo(fi.pos);
|
||||
}
|
||||
|
||||
grouptopic.GetAdd(grouppath) = GetFileTitle(fn);
|
||||
|
|
@ -147,6 +147,8 @@ void TopicEditor::SaveTopic()
|
|||
|
||||
void TopicEditor::Flush()
|
||||
{
|
||||
if(IsNull(topicpath))
|
||||
return;
|
||||
SaveTopic();
|
||||
FileInfo& fi = editstate.GetAdd(topicpath);
|
||||
fi.time = FileGetTime(topicpath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue