This commit is contained in:
Mirek Fidler 2023-08-06 18:07:24 +02:00
commit d76815cb46
15 changed files with 1789 additions and 1732 deletions

View file

@ -1,7 +1,7 @@
topic "U++ FAQ";
[l288;i1120;a17;O9;~~~.1408;2 $$1,0#10431211400427159095818037425705:param]
[a83;*R6 $$2,5#31310162474203024125188417583966:caption]
[b167;*4 $$3,5#07864147445237544204411237157677:title]
[b167;t300;*4 $$3,5#07864147445237544204411237157677:title]
[i288;O9;C2 $$4,6#40027414424643823182269349404212:item]
[b42;a42;2 $$5,5#45413000475342174754091244180557:text]
[l288;b17;a17;2 $$6,6#27521748481378242620020725143825:desc]
@ -35,7 +35,7 @@ that you have created inside this directory, e.g. in MyApps folder.&]
[s22; [^topic`:`/`/CtrlLib`/src`/index`$en`-us^ Yes.]&]
[s23; Can I create OCX Control using U`+`+?&]
[s22; [^topic`:`/`/Ole`/srcdoc`/ocx`$en`-us^ Yes you can.]&]
[s23; When compiling using Visual C`+`+ 2005 compiler, I am getting
[s23; When compiling using Visual C`+`+ 2021 compiler, I am getting
errors like:&]
[s0;l128; [/C1 F:`\upp`\uppsrc`\CtrlLib/CtrlLib.t : warning C4819: The
file contains a character that cannot be represented in the current
@ -200,4 +200,16 @@ more information in our official documentation available on our
with U`+`+. If this doesn`'t help, you can always ask you question
on our official [^http`:`/`/www`.ultimatepp`.org`/forums`/^ forum].&]
[s23; The image on this site is too small. How can I make it bigger?&]
[s22; Simply, click on it.]]
[s22; Simply, click on it.&]
[s23; What is the official name of the project?&]
[s22;%- As of today, [* the official name of the project is U`+`+].
This name should only be used in the context of our project.&]
[s22;%- In the past, we used the name of Ultimate`+`+. However, we
came to the conclusion that this name doesn`'t fit well with
our project and has certain drawbacks. [* U`+`+ is simple, powerful,
and sufficient for our needs].&]
[s22;%- If you plan to write an article or book about our framework,
please make sure you use our current official name. From a marketing
point of view, we need to focus only on one name and not use
any substitutions or alternative names.&]
[s22; ]]

File diff suppressed because it is too large Load diff

View file

@ -294,6 +294,7 @@ void RichEdit::StdBar(Bar& menu)
menu.Separator();
}
PasteTool(menu);
PastePlainTextTool(menu);
ObjectTool(menu);
}
}

View file

@ -754,6 +754,7 @@ public:
void CutTool(Bar& bar, dword key = K_CTRL_X);
void CopyTool(Bar& bar, dword key = K_CTRL_C);
void PasteTool(Bar& bar, dword key = K_CTRL_V);
void PastePlainTextTool(Bar& bar, dword key = K_CTRL_V|K_SHIFT);
void ObjectTool(Bar& bar, dword key = 0);
void LoadImageTool(Bar& bar, dword key = 0);
void FindReplaceTool(Bar& bar, dword key = K_CTRL_F);

View file

@ -317,6 +317,15 @@ void RichEdit::PasteTool(Bar& bar, dword key)
.Key(key);
}
void RichEdit::PastePlainTextTool(Bar& bar, dword key)
{
bar.Add(!IsReadOnly() && IsClipboardAvailableText(), t_("Paste without formating"), [=] {
useraction = true;
PasteText(AsRichText(ReadClipboardUnicodeText(), GetFormatInfo()));
})
.Key(K_CTRL_V|K_SHIFT);
}
void RichEdit::ObjectTool(Bar& bar, dword key)
{
for(int i = 0; i < RichObject::GetTypeCount(); i++) {

View file

@ -162,7 +162,7 @@ void TrivialHtmlParser::ReadStyle(Style& fmt, const String& style)
auto ReadLengthPar = [&](int& tsize, double psize = 2000) {
double l;
if(ReadLength(l, psize))
tsize = l;
tsize = (int)l;
};
auto ReadLengthParAdd = [&](int& tsize, double psize = 2000) {
int n = 0;
@ -219,7 +219,7 @@ void TrivialHtmlParser::ReadStyle(Style& fmt, const String& style)
auto FontSize = [&] {
double l;
if(ReadLength(l, parent_fmt.GetHeight()))
fmt.Height(l);
fmt.Height((int)l);
else {
l = base_font.GetHeight();
if(p.Id("xx-small"))
@ -255,7 +255,7 @@ void TrivialHtmlParser::ReadStyle(Style& fmt, const String& style)
else
return false;
}
fmt.Height(l);
fmt.Height((int)l);
}
return true;
};
@ -325,10 +325,10 @@ void TrivialHtmlParser::ReadStyle(Style& fmt, const String& style)
break;
}
switch(m.GetCount()) {
case 1: r.left = r.right = r.top = r.bottom = m[0]; break;
case 2: r.left = r.right = m[1]; r.top = r.bottom = m[0]; break;
case 3: r.left = r.right = m[1]; r.top = m[0]; r.bottom = m[2]; break;
case 4: r.left = m[3]; r.right = m[1]; r.top = m[0]; r.bottom = m[2]; break;
case 1: r.left = r.right = r.top = r.bottom = (int)m[0]; break;
case 2: r.left = r.right = (int)m[1]; r.top = r.bottom = (int)m[0]; break;
case 3: r.left = r.right = (int)m[1]; r.top = (int)m[0]; r.bottom = (int)m[2]; break;
case 4: r.left = (int)m[3]; r.right = (int)m[1]; r.top = (int)m[0]; r.bottom = (int)m[2]; break;
default:;
}
};

View file

@ -524,7 +524,7 @@ String EncodeHtml(const RichText& text, Index<String>& css,
return EncodeHtml(text, css, links, VectorMap<String, String>(), path, base, z);
}
RichText ParseTrivialHtml(const char *html, Font base_font = Serif(15 * 600 / 96.0));
RichText ParseTrivialHtml(const char *html, Font base_font = Serif(int(15 * 600 / 96.0)));
struct SimplePageDraw : PageDraw {
Draw& w;

View file

@ -159,8 +159,8 @@ String Ide::GetFoundText(const ArrayCtrl& list)
if(list.GetCount()) {
Value v = list.Get(0, "INFO");
bool err = true;
if(v.Is<ErrorInfo>()) {
const ErrorInfo& f = ValueTo<ErrorInfo>(v);
if(v.Is<ListLineInfo>()) {
const ListLineInfo& f = ValueTo<ListLineInfo>(v);
if(*f.message == '\1') {
Vector<String> h = Split(~f.message + 1, '\1', false);
if(h.GetCount() > 3)

View file

@ -236,6 +236,7 @@ void TopicEditor::EditMenu(Bar& bar)
editor.CutTool(bar);
editor.CopyTool(bar);
editor.PasteTool(bar);
editor.PastePlainTextTool(bar);
editor.InsertImageTool(bar);
bar.Separator();
editor.UndoTool(bar);

View file

@ -1,6 +1,6 @@
#include "ide.h"
bool Ide::FindLineError(const String& ln, FindLineErrorCache& cache, ErrorInfo& f)
bool Ide::FindLineError(const String& ln, FindLineErrorCache& cache, ListLineInfo& f)
{
if(!cache.init) {
VectorMap<String, String> bm = GetMethodVars(method);
@ -184,7 +184,7 @@ bool Ide::Next(ArrayCtrl& a, int d)
c += d;
if(c >= 0 && c < a.GetCount()) {
Value v = a.Get(c, "INFO");
if(v.Is<ErrorInfo>() && !IsNull(v.To<ErrorInfo>().file)) {
if(v.Is<ListLineInfo>() && !IsNull(v.To<ListLineInfo>().file)) {
a.SetCursor(c);
return true;
}
@ -238,7 +238,7 @@ void Ide::SetErrorEditor()
Vector<String> errorfiles;
FindLineErrorCache cache;
for(int i = 0; i < console.GetLineCount(); i++) {
ErrorInfo f;
ListLineInfo f;
if(FindLineError(console.GetUtf8Line(i), cache, f)) {
String file = NormalizePath(f.file);
#ifdef PLATFORM_WIN32
@ -253,7 +253,7 @@ void Ide::SetErrorEditor()
SetErrorFiles(errorfiles);
}
void Ide::GoToError(const ErrorInfo& f, bool error)
void Ide::GoToError(const ListLineInfo& f, bool error)
{
if(IsNull(f.file))
return;
@ -277,12 +277,12 @@ void Ide::GoToError(const ErrorInfo& f, bool error)
void Ide::GoToError(ArrayCtrl& a, bool error)
{
Value v = a.Get("INFO");
if(v.Is<ErrorInfo>())
GoToError(ValueTo<ErrorInfo>(v), error);
if(v.Is<ListLineInfo>())
GoToError(ValueTo<ListLineInfo>(v), error);
}
bool Ide::FindLineError(int l) {
ErrorInfo f;
ListLineInfo f;
FindLineErrorCache cache;
if(FindLineError(console.GetUtf8Line(l), cache, f)) {
GoToError(f, true);
@ -319,7 +319,7 @@ void Ide::PutLinkingEnd(bool ok)
error.Add(Null, Null, AttrText("Linking has failed").Bold()
.NormalPaper(HighlightSetup::GetHlStyle(HighlightSetup::PAPER_ERROR).color));
for(int i = 0; i < linking_line.GetCount(); i++) {
ErrorInfo f;
ListLineInfo f;
if(!FindLineError(linking_line[i], error_cache, f)) {
f.file = Null;
f.lineno = Null;
@ -469,7 +469,7 @@ void Ide::ConsoleLine(const String& line, bool assist)
linking_line.Add(line);
return;
}
ErrorInfo f;
ListLineInfo f;
if(FindLineError(line, error_cache, f)) {
if(assist)
f.kind = 1;
@ -498,7 +498,7 @@ void Ide::ConsoleLine(const String& line, bool assist)
}
else {
int q = line.FindAfter(" from "); // GCC style "included from"
ErrorInfo fi;
ListLineInfo fi;
if(q >= 0 && FindLineError(line.Mid(q), error_cache, fi)) {
fi.message = line;
prenotes.Add(RawToValue(fi));
@ -519,7 +519,7 @@ void Ide::ConsoleLine(const String& line, bool assist)
iserrorpos = false;
int i = n.GetCount() - 1;
if(iserrorpos && i >= 0) {
ErrorInfo f0 = ValueTo<ErrorInfo>(n[i]);
ListLineInfo f0 = ValueTo<ListLineInfo>(n[i]);
f0.error_pos = f.message;
n.Set(i, RawToValue(f0));
}
@ -620,7 +620,7 @@ void Ide::SelError()
ValueArray n = v;
int ii = error.GetCursor();
for(int i = 0; i < n.GetCount(); i++) {
const ErrorInfo& f = ValueTo<ErrorInfo>(n[i]);
const ListLineInfo& f = ValueTo<ListLineInfo>(n[i]);
bool ok = true;
for(const char *s = f.message; *s; s++)
if((byte)*s >= 128) { // clang UTF-8 is messy, just ignore those notes

View file

@ -115,12 +115,13 @@ bool Match(const char *f, const char *s, bool we, bool ignorecase, int& count) {
void Ide::AddFoundFile(const String& fn, int ln, const String& line, int pos, int count)
{
ErrorInfo f;
ListLineInfo f;
f.file = fn;
f.lineno = ln;
f.linepos = pos + 1;
f.len = count;
f.kind = 0;
f.line = line;
f.message = "\1" + EditorSyntax::GetSyntaxForFilename(fn) + "\1" +
AsString(pos) + "\1" + AsString(count) + "\1" + (line.GetCount() > 5000 ? line.Mid(0, 5000) : line);
FFound().Add(fn, ln, f.message, RawToValue(f));
@ -291,7 +292,7 @@ void Ide::FindInFiles(bool replace) {
break;
}
else {
ErrorInfo f;
ListLineInfo f;
f.file = files[i];
f.lineno = 1;
f.linepos = 0;
@ -538,8 +539,8 @@ void Ide::ReplaceFound(ArrayCtrl& list)
Index<String> ch;
for(int i = 0; i < list.GetCount() && ch.GetCount() < 6; i++) {
Value v = list.Get(i, "INFO");
if(v.Is<ErrorInfo>()) {
const ErrorInfo& f = ValueTo<ErrorInfo>(v);
if(v.Is<ListLineInfo>()) {
const ListLineInfo& f = ValueTo<ListLineInfo>(v);
if(*f.message == '\1') {
Vector<String> h = Split(~f.message + 1, '\1', false);
if(h.GetCount() > 3 && f.linepos > 0)
@ -577,8 +578,8 @@ void Ide::ReplaceFound(ArrayCtrl& list)
for(int i = 0; i < list.GetCount(); i++) {
Value v = list.Get(i, "INFO");
bool err = true;
if(v.Is<ErrorInfo>()) {
const ErrorInfo& f = ValueTo<ErrorInfo>(v);
if(v.Is<ListLineInfo>()) {
const ListLineInfo& f = ValueTo<ListLineInfo>(v);
if(*f.message == '\1') {
Vector<String> h = Split(~f.message + 1, '\1', false);
if(h.GetCount() > 3) {
@ -659,9 +660,9 @@ void Ide::ReplaceFound(ArrayCtrl& list)
if(i >= 0 && i < list.GetCount()) {
Value v = list.Get(i, "INFO");
bool err = true;
if(v.Is<ErrorInfo>()) {
const ErrorInfo& f0 = ValueTo<ErrorInfo>(v);
ErrorInfo f = f0;
if(v.Is<ListLineInfo>()) {
const ListLineInfo& f0 = ValueTo<ListLineInfo>(v);
ListLineInfo f = f0;
if(*f.message == '\1') {
String l = line.value.a;
f.linepos = r.a + 1;

View file

@ -235,8 +235,8 @@ void Ide::UsageId(const String& name, const String& id, const Index<String>& ids
void Ide::UsageFinish()
{
FFound().Sort(3, [](const Value& va, const Value& vb)->int {
const ErrorInfo& a = va.To<ErrorInfo>();
const ErrorInfo& b = vb.To<ErrorInfo>();
const ListLineInfo& a = va.To<ListLineInfo>();
const ListLineInfo& b = vb.To<ListLineInfo>();
return CombineCompare(GetFileName(a.file), GetFileName(b.file))
(a.file, b.file)
(a.lineno, b.lineno)
@ -279,16 +279,45 @@ void Ide::FindDesignerItemReferences(const String& id, const String& name)
int q = CodeIndex().Find(path);
if(q < 0)
return;
auto DoUsage = [&](const AnnotationItem& m) {
Index<String> ids, unique;
ids.Add(m.id);
NewFFound();
UsageId(name, m.id, ids, IsStruct(m.kind), m.isstatic, unique);
UsageFinish();
};
for(const AnnotationItem& m : CodeIndex()[q].items) {
if(m.id.EndsWith(id) &&
(m.id.GetCount() <= id.GetCount() || !iscid(m.id[m.id.GetCount() - id.GetCount() - 1]))) {
Index<String> ids, unique;
ids.Add(m.id);
NewFFound();
UsageId(name, m.id, ids, IsStruct(m.kind), m.isstatic, unique);
UsageFinish();
DoUsage(m);
return;
}
}
// Probably untyped layout item, need to find all classes using the layout
q = id.ReverseFind("::");
if(q < 0) return;
String bclst = id.Mid(0, q);
String nbclst = ":" + id.Mid(0, q);
String var = id.Mid(q + 2);
Index<String> vars;
for(const auto& f : ~CodeIndex())
for(const AnnotationItem& m : f.value.items) {
if(IsStruct(m.kind) && m.bases.GetCount()) {
for(String bcls : Split(m.bases, [](int c) { return iscid(c) || c == ':' ? 0 : 1; })) {
if(bcls == bclst || bcls.EndsWith(nbclst)) {
vars.FindAdd(m.id + "::" + var);
}
}
}
}
for(const auto& f : ~CodeIndex())
for(const AnnotationItem& m : f.value.items) {
if(IsVariable(m.kind) && vars.Find(m.id) >= 0) {
DoUsage(m);
}
}
}

View file

@ -103,7 +103,7 @@ void Ide::Valgrind()
p.Skip();
}
if(dir.GetCount() && file.GetCount() && !IsNull(line)) {
ErrorInfo f;
ListLineInfo f;
String p = AppendFileName(dir, file);
f.lineno = Null;
if(FileExistsCached(p)) {
@ -127,7 +127,7 @@ void Ide::Valgrind()
else
p.Skip();
}
ErrorInfo f;
ListLineInfo f;
f.file = path;
f.lineno = lineno;
f.linepos = 0;

View file

@ -1052,7 +1052,7 @@ public:
void Clear() { init = false; file.Clear(); wspc_paths.Clear(); }
};
struct ErrorInfo {
struct ListLineInfo { // either error or found list (find in files / usage)
String file;
int lineno;
int linepos;
@ -1060,8 +1060,9 @@ public:
int kind;
String message;
String error_pos;
String line;
ErrorInfo() { lineno = linepos = kind = len = 0; }
ListLineInfo() { lineno = linepos = kind = len = 0; }
};
FindLineErrorCache error_cache;
@ -1100,10 +1101,10 @@ public:
};
bool FindLineError(int l);
void GoToError(const ErrorInfo& f, bool error);
void GoToError(const ListLineInfo& f, bool error);
void GoToError(ArrayCtrl& a, bool error);
bool FindLineError(const String& ln, FindLineErrorCache& cache, ErrorInfo& f);
bool FindLineError(const String& ln, FindLineErrorCache& cache, ListLineInfo& f);
void FindError();
void FindWildcard();

View file

@ -131,7 +131,8 @@ void Ide::InsertAdvanced(Bar& bar)
void Ide::Reformat(Bar& bar)
{
bar.Sub("Reformat", [=] (Bar& menu) { ReformatMenu(menu); });
bool b = !editor.IsReadOnly() && !designer;
bar.Sub(b, "Reformat", [=] (Bar& menu) { ReformatMenu(menu); });
}
void Ide::EditSpecial(Bar& menu)