mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
fix: horizontal scrollbar calculations for C/C++ view
- added msvc define NOMINMAX so we can use std::max
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\third_party\fadec\;..\third_party\raw_pdb\src\;..\third_party\qscintilla\src\;..\src\</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>dwmapi.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -80,6 +81,7 @@
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\third_party\fadec\;..\third_party\raw_pdb\src\;..\third_party\qscintilla\src\;..\src\</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<PostBuildEvent>
|
||||
<Command>$(QtToolsPath)/windeployqt $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName).exe</Command>
|
||||
|
||||
15
src/main.cpp
15
src/main.cpp
@@ -2263,6 +2263,21 @@ void MainWindow::updateRenderedView(TabState& tab, SplitPane& pane) {
|
||||
// Set text
|
||||
pane.rendered->setText(text);
|
||||
|
||||
// Set horizontal scroll width to match the longest line (ignoring trailing spaces)
|
||||
{
|
||||
int maxLen = 0;
|
||||
const QStringList lines = text.split(QChar('\n'));
|
||||
for (const auto& line : lines) {
|
||||
int len = (int)line.size();
|
||||
while (len > 0 && line[len - 1] == QChar(' ')) --len;
|
||||
maxLen = std::max(maxLen, len);
|
||||
}
|
||||
QFontMetrics fm(pane.rendered->font());
|
||||
int pixelWidth = fm.horizontalAdvance(QString(maxLen, QChar('0')));
|
||||
pane.rendered->SendScintilla(QsciScintillaBase::SCI_SETSCROLLWIDTH,
|
||||
(unsigned long)qMax(1, pixelWidth));
|
||||
}
|
||||
|
||||
// Update margin width for line count
|
||||
int lineCount = pane.rendered->lines();
|
||||
QString marginStr = QString(QString::number(lineCount).size() + 2, '0');
|
||||
|
||||
Reference in New Issue
Block a user