Merge pull request #56 from marcel303/undoIndexFix

Fix for undo index not being reset to 0 after loading files,
diff --git a/TextEditor.cpp b/TextEditor.cpp
index c1c7e34..4d9bfdd 100644
--- a/TextEditor.cpp
+++ b/TextEditor.cpp
@@ -62,7 +62,7 @@
 

 void TextEditor::SetPalette(const Palette & aValue)

 {

-	mPalette = aValue;

+	mPaletteBase = aValue;

 }

 

 int TextEditor::AppendBuffer(std::string& aBuffer, char chr, int aIndex)

@@ -613,7 +613,15 @@
 	/* Compute mCharAdvance regarding to scaled font size (Ctrl + mouse wheel)*/

 	const float fontSize = ImGui::CalcTextSize("#").x;

 	mCharAdvance = ImVec2(fontSize, ImGui::GetTextLineHeightWithSpacing() * mLineSpacing);

-

+
+	/* Update palette with the current alpha from style */
+	for (int i = 0; i < (int)PaletteIndex::Max; ++i)
+	{
+		auto color = ImGui::ColorConvertU32ToFloat4(mPaletteBase[i]);
+		color.w *= ImGui::GetStyle().Alpha;
+		mPalette[i] = ImGui::ColorConvertFloat4ToU32(color);
+	}
+	

 	static std::string buffer;

 	auto contentSize = ImGui::GetWindowContentRegionMax();

 	auto drawList = ImGui::GetWindowDrawList();

diff --git a/TextEditor.h b/TextEditor.h
index ac03ad4..93a6bd7 100644
--- a/TextEditor.h
+++ b/TextEditor.h
@@ -181,7 +181,7 @@
 	void SetLanguageDefinition(const LanguageDefinition& aLanguageDef);

 	const LanguageDefinition& GetLanguageDefinition() const { return mLanguageDefinition; }

 

-	const Palette& GetPalette() const { return mPalette; }

+	const Palette& GetPalette() const { return mPaletteBase; }

 	void SetPalette(const Palette& aValue);

 

 	void SetErrorMarkers(const ErrorMarkers& aMarkers) { mErrorMarkers = aMarkers; }

@@ -334,7 +334,8 @@
 	bool mCursorPositionChanged;

 	int mColorRangeMin, mColorRangeMax;

 	SelectionMode mSelectionMode;

-

+
+	Palette mPaletteBase;

 	Palette mPalette;

 	LanguageDefinition mLanguageDefinition;

 	RegexList mRegexList;