ui: Improved scrolling and layouting in QtCodeView and colored locations of active TokenId differently
This commit is contained in:
@@ -58,6 +58,16 @@ void ApplicationSettings::setCodeLinkColor(Colori codeLinkColor)
|
||||
setValue<std::string>("code/LinkColor", codeLinkColor.toString());
|
||||
}
|
||||
|
||||
Colori ApplicationSettings::getCodeActiveLinkColor() const
|
||||
{
|
||||
return Colori::fromString(getValue<std::string>("code/ActiveLinkColor", Colori(0, 255, 0, 100).toString()));
|
||||
}
|
||||
|
||||
void ApplicationSettings::setCodeActiveLinkColor(Colori codeLinkColor)
|
||||
{
|
||||
setValue<std::string>("code/ActiveLinkColor", codeLinkColor.toString());
|
||||
}
|
||||
|
||||
ApplicationSettings::ApplicationSettings()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ public:
|
||||
Colori getCodeLinkColor() const;
|
||||
void setCodeLinkColor(Colori codeLinkColor);
|
||||
|
||||
Colori getCodeActiveLinkColor() const;
|
||||
void setCodeActiveLinkColor(Colori codeLinkColor);
|
||||
|
||||
private:
|
||||
ApplicationSettings();
|
||||
ApplicationSettings(const ApplicationSettings&);
|
||||
|
||||
@@ -29,6 +29,7 @@ void CodeController::setActiveTokenId(Id id)
|
||||
collection.forEachTokenLocation([&] (TokenLocation* tokenLocation) -> void {
|
||||
if (tokenLocation->isStartTokenLocation())
|
||||
{
|
||||
CodeView::CodeSnippetParams params;
|
||||
const std::string filePath = tokenLocation->getFilePath();
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath);
|
||||
|
||||
@@ -37,14 +38,17 @@ void CodeController::setActiveTokenId(Id id)
|
||||
textAccess->getLineCount(), tokenLocation->getEndTokenLocation()->getLineNumber() + lineRadius
|
||||
);
|
||||
|
||||
std::string text;
|
||||
for (std::string line: textAccess->getLines(firstLineNumber, lastLineNumber))
|
||||
{
|
||||
text += line;
|
||||
params.code += line;
|
||||
}
|
||||
|
||||
TokenLocationFile tokenLocationFile = m_locationAccess->getTokenLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber);
|
||||
getView()->addCodeSnippet(text, tokenLocationFile, firstLineNumber);
|
||||
params.startLineNumber = firstLineNumber;
|
||||
params.locationFile =
|
||||
m_locationAccess->getTokenLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber);
|
||||
params.activeTokenId = id;
|
||||
|
||||
getView()->addCodeSnippet(params);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
#include "component/controller/CodeController.h"
|
||||
|
||||
CodeView::CodeSnippetParams::CodeSnippetParams()
|
||||
: locationFile("")
|
||||
{
|
||||
}
|
||||
|
||||
CodeView::CodeView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100, 100))
|
||||
{
|
||||
|
||||
@@ -2,19 +2,30 @@
|
||||
#define CODE_VIEW_H
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class CodeController;
|
||||
class TokenLocationFile;
|
||||
|
||||
class CodeView: public View
|
||||
{
|
||||
public:
|
||||
struct CodeSnippetParams
|
||||
{
|
||||
CodeSnippetParams();
|
||||
|
||||
std::string code;
|
||||
TokenLocationFile locationFile;
|
||||
int startLineNumber;
|
||||
Id activeTokenId;
|
||||
};
|
||||
|
||||
CodeView(ViewLayout* viewLayout);
|
||||
virtual ~CodeView();
|
||||
|
||||
virtual std::string getName() const;
|
||||
|
||||
virtual void addCodeSnippet(const std::string& str, const TokenLocationFile& locationFile, int startLineNumber) = 0;
|
||||
virtual void addCodeSnippet(const CodeSnippetParams params) = 0;
|
||||
virtual void clearCodeSnippets() = 0;
|
||||
|
||||
private:
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
TokenLocationLine* createTokenLocationLine(unsigned int lineNumber);
|
||||
|
||||
std::map<unsigned int, std::shared_ptr<TokenLocationLine> > m_lines;
|
||||
const std::string m_filePath;
|
||||
std::string m_filePath;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& ostream, const TokenLocationFile& file);
|
||||
|
||||
Reference in New Issue
Block a user