mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-27 16:38:20 +03:00
Minor fixes and improvements.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <eepp/window/engine.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -387,6 +388,8 @@ const Glyph& FontTrueType::getGlyph( Uint32 codePoint, unsigned int characterSiz
|
||||
const Glyph& FontTrueType::getGlyphByIndex( Uint32 index, unsigned int characterSize, bool bold,
|
||||
bool italic, Float outlineThickness, Page& page,
|
||||
const Float& maxWidth ) const {
|
||||
eeASSERT( Window::Engine::isRunninMainThread() );
|
||||
|
||||
// Get the page corresponding to the character size
|
||||
GlyphTable& glyphs = page.glyphs;
|
||||
|
||||
|
||||
+24
-18
@@ -912,16 +912,16 @@ void Text::ensureGeometryUpdate() {
|
||||
mOutlineVertices.clear();
|
||||
mBounds = Rectf();
|
||||
|
||||
// No font or text: nothing to draw
|
||||
if ( !mFont || mString.empty() )
|
||||
return;
|
||||
|
||||
mVertices.reserve( mString.size() * GLi->quadVertexs() );
|
||||
mGlyphCache.reserve( mString.size() );
|
||||
|
||||
if ( mOutlineThickness != 0.f )
|
||||
mOutlineVertices.reserve( mString.size() * GLi->quadVertexs() );
|
||||
|
||||
// No font or text: nothing to draw
|
||||
if ( !mFont || mString.empty() )
|
||||
return;
|
||||
|
||||
// Compute values related to the text style
|
||||
bool bold = ( mStyle & Bold ) != 0;
|
||||
bool reqItalic = ( mStyle & Italic ) != 0;
|
||||
@@ -955,16 +955,18 @@ void Text::ensureGeometryUpdate() {
|
||||
Uint32 prevChar = 0;
|
||||
|
||||
Float centerDiffX = 0;
|
||||
unsigned int Line = 0;
|
||||
unsigned int line = 0;
|
||||
|
||||
switch ( Font::getHorizontalAlign( mAlign ) ) {
|
||||
case TEXT_ALIGN_CENTER:
|
||||
centerDiffX = (Float)( (Int32)( ( mCachedWidth - mLinesWidth[Line] ) * 0.5f ) );
|
||||
Line++;
|
||||
centerDiffX = line < mLinesWidth.size()
|
||||
? (Float)( (Int32)( ( mCachedWidth - mLinesWidth[line] ) * 0.5f ) )
|
||||
: 0.f;
|
||||
line++;
|
||||
break;
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
centerDiffX = mCachedWidth - mLinesWidth[Line];
|
||||
Line++;
|
||||
centerDiffX = line < mLinesWidth.size() ? mCachedWidth - mLinesWidth[line] : 0.f;
|
||||
line++;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -998,14 +1000,18 @@ void Text::ensureGeometryUpdate() {
|
||||
if ( curChar == L'\n' ) {
|
||||
switch ( Font::getHorizontalAlign( mAlign ) ) {
|
||||
case TEXT_ALIGN_CENTER:
|
||||
centerDiffX = (Float)( (Int32)( ( mCachedWidth - mLinesWidth[Line] ) * 0.5f ) );
|
||||
centerDiffX =
|
||||
line < mLinesWidth.size()
|
||||
? (Float)( (Int32)( ( mCachedWidth - mLinesWidth[line] ) * 0.5f ) )
|
||||
: 0.f;
|
||||
break;
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
centerDiffX = mCachedWidth - mLinesWidth[Line];
|
||||
centerDiffX =
|
||||
line < mLinesWidth.size() ? mCachedWidth - mLinesWidth[line] : 0.f;
|
||||
break;
|
||||
}
|
||||
|
||||
Line++;
|
||||
line++;
|
||||
}
|
||||
|
||||
// Handle special characters
|
||||
@@ -1017,17 +1023,17 @@ void Text::ensureGeometryUpdate() {
|
||||
|
||||
switch ( curChar ) {
|
||||
case ' ':
|
||||
mGlyphCache.push_back(
|
||||
mGlyphCache.emplace_back(
|
||||
Rectf( Vector2f( x, y - mRealFontSize ), Sizef( hspace, vspace ) ) );
|
||||
x += hspace;
|
||||
break;
|
||||
case '\t':
|
||||
mGlyphCache.push_back( Rectf( Vector2f( x, y - mRealFontSize ),
|
||||
Sizef( hspace * mTabWidth, vspace ) ) );
|
||||
mGlyphCache.emplace_back( Rectf( Vector2f( x, y - mRealFontSize ),
|
||||
Sizef( hspace * mTabWidth, vspace ) ) );
|
||||
x += hspace * mTabWidth;
|
||||
break;
|
||||
case '\n':
|
||||
mGlyphCache.push_back(
|
||||
mGlyphCache.emplace_back(
|
||||
Rectf( Vector2f( x, y - mRealFontSize ), Sizef( 0, vspace ) ) );
|
||||
y += vspace;
|
||||
x = 0;
|
||||
@@ -1084,14 +1090,14 @@ void Text::ensureGeometryUpdate() {
|
||||
maxY = std::max( maxY, y + bottom );
|
||||
}
|
||||
|
||||
mGlyphCache.push_back(
|
||||
mGlyphCache.emplace_back(
|
||||
Rectf( Vector2f( x, y - mRealFontSize ), Sizef( glyph.advance, vspace ) ) );
|
||||
|
||||
// Advance to the next character
|
||||
x += glyph.advance;
|
||||
}
|
||||
|
||||
mGlyphCache.push_back( Rectf( Vector2f( x, y - mRealFontSize ), Sizef( 0, vspace ) ) );
|
||||
mGlyphCache.emplace_back( Rectf( Vector2f( x, y - mRealFontSize ), Sizef( 0, vspace ) ) );
|
||||
|
||||
// If we're using the underlined style, add the last line
|
||||
if ( underlined && ( x > 0 ) ) {
|
||||
|
||||
@@ -1533,12 +1533,13 @@ void App::updateDocInfo( TextDocument& doc ) {
|
||||
mSplitter->curEditorExistsAndFocused() ) {
|
||||
mDocInfo->setVisible( true );
|
||||
updateDocInfoLocation();
|
||||
mDocInfo->setText( String::format(
|
||||
String infoStr( String::format(
|
||||
"%s: %lld / %zu %s: %lld %s", i18n( "line_abbr", "line" ).toUtf8().c_str(),
|
||||
doc.getSelection().start().line() + 1, doc.linesCount(),
|
||||
i18n( "col_abbr", "col" ).toUtf8().c_str(),
|
||||
mSplitter->getCurEditor()->getCurrentColumnCount(),
|
||||
TextDocument::lineEndingToString( doc.getLineEnding() ).c_str() ) );
|
||||
mDocInfo->runOnMainThread( [this, infoStr] { mDocInfo->setText( infoStr ); } );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -620,10 +620,12 @@ PluginRequestHandle GlobalSearchController::processMessage( const PluginMessage&
|
||||
sample.line.substr( sample.position.start().column(),
|
||||
sample.position.end().column() - sample.position.start().column() );
|
||||
|
||||
showGlobalSearch( false );
|
||||
mGlobalSearchInput->setText( search );
|
||||
updateGlobalSearchHistory( model, search, false, false, false );
|
||||
updateGlobalSearchBarResults( search, model, false, false );
|
||||
mUISceneNode->runOnMainThread( [this, search, model] {
|
||||
showGlobalSearch( false );
|
||||
mGlobalSearchInput->setText( search );
|
||||
updateGlobalSearchHistory( model, search, false, false, false );
|
||||
updateGlobalSearchBarResults( search, model, false, false );
|
||||
} );
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1578,7 +1578,7 @@ void LSPClientServer::publishDiagnostics( const json& msg ) {
|
||||
PluginMessageType::Diagnostics,
|
||||
PluginMessageFormat::Diagnostics, &res );
|
||||
}
|
||||
Log::debug( "LSPClientServer::publishDiagnostics: %s - returned %zu items",
|
||||
Log::info( "LSPClientServer::publishDiagnostics: %s - returned %zu items",
|
||||
res.uri.toString().c_str(), res.diagnostics.size() );
|
||||
Log::debug( "LSPClientServer::publishDiagnostics: %s", msg.dump().c_str() );
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ LSPDocumentClient::LSPDocumentClient( LSPClientServer* server, TextDocument* doc
|
||||
}
|
||||
|
||||
LSPDocumentClient::~LSPDocumentClient() {
|
||||
mDoc = nullptr;
|
||||
UISceneNode* sceneNode = getUISceneNode();
|
||||
if ( nullptr != sceneNode && 0 != mTag )
|
||||
sceneNode->removeActionsByTag( mTag );
|
||||
@@ -32,6 +33,7 @@ LSPDocumentClient::~LSPDocumentClient() {
|
||||
}
|
||||
|
||||
void LSPDocumentClient::onDocumentLoaded( TextDocument* ) {
|
||||
refreshTag();
|
||||
requestSemanticHighlightingDelayed();
|
||||
// requestCodeLens();
|
||||
}
|
||||
@@ -251,6 +253,9 @@ static std::string semanticTokenTypeToSyntaxType( const std::string& type,
|
||||
|
||||
void LSPDocumentClient::processTokens( const LSPSemanticTokensDelta& tokens,
|
||||
const Uint64& docModificationId ) {
|
||||
if ( mDoc == nullptr || mServer == nullptr )
|
||||
return;
|
||||
|
||||
// If the document has already being modified after requesting the semantic highlighting,
|
||||
// re-request the changes
|
||||
if ( docModificationId != mDoc->getModificationId() )
|
||||
|
||||
@@ -205,13 +205,16 @@ void StatusBuildOutputController::runBuild( const std::string& buildName,
|
||||
|
||||
const auto updateBuildButton = [this, enableCleanButton]() {
|
||||
UIPushButton* buildButton = getBuildButton( mApp );
|
||||
if ( buildButton )
|
||||
buildButton->setText( mApp->i18n( "build", "Build" ) );
|
||||
if ( buildButton ) {
|
||||
buildButton->runOnMainThread(
|
||||
[this, buildButton] { buildButton->setText( mApp->i18n( "build", "Build" ) ); } );
|
||||
}
|
||||
|
||||
if ( enableCleanButton ) {
|
||||
UIPushButton* cleanButton = getCleanButton( mApp );
|
||||
if ( cleanButton )
|
||||
cleanButton->setEnabled( true );
|
||||
if ( cleanButton ) {
|
||||
cleanButton->runOnMainThread( [cleanButton] { cleanButton->setEnabled( true ); } );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user