mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Just accept const char ptr in ImGuiColorTextEdit.
This commit is contained in:
parent
2c7d457755
commit
69dd0b72c1
@ -746,21 +746,22 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder)
|
||||
mWithinRender = false;
|
||||
}
|
||||
|
||||
void TextEditor::SetText(const std::string & aText)
|
||||
void TextEditor::SetText(const char* aText)
|
||||
{
|
||||
mLines.clear();
|
||||
for (auto chr : aText)
|
||||
while( *aText )
|
||||
{
|
||||
if (mLines.empty())
|
||||
mLines.push_back(Line());
|
||||
if (chr == '\n')
|
||||
if (*aText == '\n')
|
||||
mLines.push_back(Line());
|
||||
else
|
||||
{
|
||||
mLines.back().push_back(Glyph(chr, PaletteIndex::Default));
|
||||
mLines.back().push_back(Glyph(*aText, PaletteIndex::Default));
|
||||
}
|
||||
|
||||
mTextChanged = true;
|
||||
aText++;
|
||||
}
|
||||
|
||||
mUndoBuffer.clear();
|
||||
|
||||
@ -179,7 +179,7 @@ public:
|
||||
void SetBreakpoints(const Breakpoints& aMarkers) { mBreakpoints = aMarkers; }
|
||||
|
||||
void Render(const char* aTitle, const ImVec2& aSize = ImVec2(), bool aBorder = false);
|
||||
void SetText(const std::string& aText);
|
||||
void SetText(const char* aText);
|
||||
std::string GetText() const;
|
||||
std::string GetSelectedText() const;
|
||||
|
||||
|
||||
@ -416,11 +416,11 @@ void View::SetTextEditorFile( const char* fileName, int line )
|
||||
fseek( f, 0, SEEK_END );
|
||||
const auto sz = ftell( f );
|
||||
fseek( f, 0, SEEK_SET );
|
||||
std::string data;
|
||||
data.resize( sz );
|
||||
fread( data.data(), 1, sz, f );
|
||||
auto data = new char[sz];
|
||||
fread( data, 1, sz, f );
|
||||
fclose( f );
|
||||
m_textEditor->SetText( data );
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
m_textEditor->SetCursorPosition( TextEditor::Coordinates( line-1, 0 ) );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user