mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-29 17:46:29 +03:00
Minor clean up.
This commit is contained in:
@@ -130,7 +130,7 @@ class EE_API Text {
|
||||
/** Shrink the String to a max width
|
||||
* @param MaxWidth The maximum possible width
|
||||
*/
|
||||
void shrinkText( const Uint32& maxWidth );
|
||||
void wrapText( const Uint32& maxWidth );
|
||||
|
||||
/** Invalidates the color cache */
|
||||
void invalidateColors();
|
||||
|
||||
@@ -16,17 +16,17 @@ class EE_API Translator {
|
||||
public:
|
||||
Translator( const std::locale& locale = std::locale() );
|
||||
|
||||
void loadFromDirectory( std::string dirPath, std::string ext = "xml" );
|
||||
bool loadFromDirectory( std::string dirPath, std::string ext = "xml" );
|
||||
|
||||
void loadFromFile( const std::string& path, std::string lang = "" );
|
||||
bool loadFromFile( const std::string& path, std::string lang = "" );
|
||||
|
||||
void loadFromString( const std::string& string, std::string lang = "" );
|
||||
bool loadFromString( const std::string& string, std::string lang = "" );
|
||||
|
||||
void loadFromMemory( const void* buffer, Int32 bufferSize, std::string lang = "" );
|
||||
bool loadFromMemory( const void* buffer, Int32 bufferSize, std::string lang = "" );
|
||||
|
||||
void loadFromStream( IOStream& stream, std::string lang = "" );
|
||||
bool loadFromStream( IOStream& stream, std::string lang = "" );
|
||||
|
||||
void loadFromPack( Pack* pack, const std::string& FilePackPath, std::string lang = "" );
|
||||
bool loadFromPack( Pack* pack, const std::string& FilePackPath, std::string lang = "" );
|
||||
|
||||
String getString( const std::string& key, const String& defaultValue = String() );
|
||||
|
||||
@@ -50,7 +50,7 @@ class EE_API Translator {
|
||||
std::string mCurrentLanguage;
|
||||
StringLocaleDictionary mDictionary;
|
||||
|
||||
void loadNodes( pugi::xml_node node, std::string lang = "" );
|
||||
bool loadNodes( pugi::xml_node node, std::string lang = "" );
|
||||
};
|
||||
|
||||
}} // namespace EE::System
|
||||
|
||||
@@ -643,15 +643,15 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
|
||||
|
||||
virtual void drawMatchingBrackets( const Vector2f& startScroll, const Float& lineHeight );
|
||||
|
||||
virtual void drawLineText( const Int64& line, Vector2f position, const Float& fontSize,
|
||||
const Float& lineHeight );
|
||||
|
||||
virtual void drawSelectionMatch( const std::pair<int, int>& lineRange,
|
||||
const Vector2f& startScroll, const Float& lineHeight );
|
||||
|
||||
virtual void drawWordMatch( const String& text, const std::pair<int, int>& lineRange,
|
||||
const Vector2f& startScroll, const Float& lineHeight );
|
||||
|
||||
virtual void drawLineText( const Int64& index, Vector2f position, const Float& fontSize,
|
||||
const Float& lineHeight );
|
||||
|
||||
virtual void drawWhitespaces( const std::pair<int, int>& lineRange, const Vector2f& startScroll,
|
||||
const Float& lineHeight );
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class EE_API UITextEdit : public UICodeEditor {
|
||||
|
||||
virtual void setTheme( UITheme* Theme );
|
||||
|
||||
virtual void shrinkText( const Float& maxWidth );
|
||||
virtual void wrapText( const Float& maxWidth );
|
||||
|
||||
String getText() const;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
|
||||
|
||||
virtual UITextView* setText( const String& text );
|
||||
|
||||
virtual void shrinkText( const Uint32& MaxWidth );
|
||||
virtual void wrapText( const Uint32& MaxWidth );
|
||||
|
||||
UITextInput* setMaxLength( const Uint32& maxLength );
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class EE_API UITextView : public UIWidget {
|
||||
|
||||
Vector2f getAlignOffset() const;
|
||||
|
||||
virtual void shrinkText( const Uint32& MaxWidth );
|
||||
virtual void wrapText( const Uint32& maxWidth );
|
||||
|
||||
bool isTextSelectionEnabled() const;
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ void Text::getWidthInfo() {
|
||||
mNumLines = Lines;
|
||||
}
|
||||
|
||||
void Text::shrinkText( const Uint32& maxWidth ) {
|
||||
void Text::wrapText( const Uint32& maxWidth ) {
|
||||
if ( !mString.size() || NULL == mFont )
|
||||
return;
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@ Translator::Translator( const std::locale& locale ) : mDefaultLanguage( "en" ) {
|
||||
setLanguageFromLocale( locale );
|
||||
}
|
||||
|
||||
void Translator::loadFromDirectory( std::string dirPath, std::string ext ) {
|
||||
bool Translator::loadFromDirectory( std::string dirPath, std::string ext ) {
|
||||
FileSystem::dirAddSlashAtEnd( dirPath );
|
||||
bool someFailed = false;
|
||||
|
||||
if ( FileSystem::isDirectory( dirPath ) ) {
|
||||
std::vector<std::string> files = FileSystem::filesGetInPath( dirPath, true, true );
|
||||
@@ -28,13 +29,16 @@ void Translator::loadFromDirectory( std::string dirPath, std::string ext ) {
|
||||
if ( FileSystem::fileExtension( path ) == ext ) {
|
||||
std::string lang = FileSystem::fileRemoveExtension( files[i] );
|
||||
|
||||
loadFromFile( path, lang );
|
||||
if ( !loadFromFile( path, lang ) )
|
||||
someFailed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return someFailed;
|
||||
}
|
||||
|
||||
void Translator::loadNodes( pugi::xml_node node, std::string lang ) {
|
||||
bool Translator::loadNodes( pugi::xml_node node, std::string lang ) {
|
||||
for ( pugi::xml_node resources = node; resources; resources = resources.next_sibling() ) {
|
||||
std::string name = String::toLower( std::string( resources.name() ) );
|
||||
|
||||
@@ -44,7 +48,7 @@ void Translator::loadNodes( pugi::xml_node node, std::string lang ) {
|
||||
if ( lang.empty() || lang.size() != 2 ) {
|
||||
Log::error( "Error: Couldn't load i18n language strings: language not specified in "
|
||||
"file name or resources attribute \"language\"." );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( pugi::xml_node string = resources.child( "string" ); string;
|
||||
@@ -59,9 +63,10 @@ void Translator::loadNodes( pugi::xml_node node, std::string lang ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Translator::loadFromFile( const std::string& path, std::string lang ) {
|
||||
bool Translator::loadFromFile( const std::string& path, std::string lang ) {
|
||||
if ( FileSystem::fileExists( path ) ) {
|
||||
lang = lang.size() == 2
|
||||
? lang
|
||||
@@ -71,7 +76,7 @@ void Translator::loadFromFile( const std::string& path, std::string lang ) {
|
||||
pugi::xml_parse_result result = doc.load_file( path.c_str() );
|
||||
|
||||
if ( result ) {
|
||||
loadNodes( doc.first_child(), lang );
|
||||
return loadNodes( doc.first_child(), lang );
|
||||
} else {
|
||||
Log::error( "Couldn't load i18n file: %s", path.c_str() );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
@@ -82,39 +87,42 @@ void Translator::loadFromFile( const std::string& path, std::string lang ) {
|
||||
Pack* pack = PackManager::instance()->exists( packPath );
|
||||
|
||||
if ( NULL != pack ) {
|
||||
loadFromPack( pack, packPath, lang );
|
||||
return loadFromPack( pack, packPath, lang );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void Translator::loadFromString( const std::string& string, std::string lang ) {
|
||||
bool Translator::loadFromString( const std::string& string, std::string lang ) {
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_string( string.c_str() );
|
||||
|
||||
if ( result ) {
|
||||
loadNodes( doc.first_child(), lang );
|
||||
return loadNodes( doc.first_child(), lang );
|
||||
} else {
|
||||
Log::error( "Couldn't load i18n file from string: %s", string.c_str() );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
Log::error( "Error offset: %d", result.offset );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Translator::loadFromMemory( const void* buffer, Int32 bufferSize, std::string lang ) {
|
||||
bool Translator::loadFromMemory( const void* buffer, Int32 bufferSize, std::string lang ) {
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_buffer( buffer, bufferSize );
|
||||
|
||||
if ( result ) {
|
||||
loadNodes( doc.first_child(), lang );
|
||||
return loadNodes( doc.first_child(), lang );
|
||||
} else {
|
||||
Log::error( "Couldn't load i18n file from buffer" );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
Log::error( "Error offset: %d", result.offset );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Translator::loadFromStream( IOStream& stream, std::string lang ) {
|
||||
bool Translator::loadFromStream( IOStream& stream, std::string lang ) {
|
||||
if ( !stream.isOpen() )
|
||||
return;
|
||||
return false;
|
||||
|
||||
ios_size bufferSize = stream.getSize();
|
||||
TScopedBuffer<char> scopedBuffer( bufferSize );
|
||||
@@ -124,15 +132,17 @@ void Translator::loadFromStream( IOStream& stream, std::string lang ) {
|
||||
pugi::xml_parse_result result = doc.load_buffer( scopedBuffer.get(), scopedBuffer.length() );
|
||||
|
||||
if ( result ) {
|
||||
loadNodes( doc.first_child(), lang );
|
||||
return loadNodes( doc.first_child(), lang );
|
||||
} else {
|
||||
Log::error( "Couldn't load i18n file from stream" );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
Log::error( "Error offset: %d", result.offset );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Translator::loadFromPack( Pack* pack, const std::string& FilePackPath, std::string lang ) {
|
||||
bool Translator::loadFromPack( Pack* pack, const std::string& FilePackPath, std::string lang ) {
|
||||
ScopedBuffer buffer;
|
||||
|
||||
if ( pack->isOpen() && pack->extractFileToMemory( FilePackPath, buffer ) ) {
|
||||
@@ -141,8 +151,10 @@ void Translator::loadFromPack( Pack* pack, const std::string& FilePackPath, std:
|
||||
? lang
|
||||
: FileSystem::fileRemoveExtension( FileSystem::fileNameFromPath( FilePackPath ) );
|
||||
|
||||
loadFromMemory( buffer.get(), buffer.length(), lang );
|
||||
return loadFromMemory( buffer.get(), buffer.length(), lang );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
String Translator::getString( const std::string& key, const String& defaultValue ) {
|
||||
|
||||
@@ -1004,7 +1004,8 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() {
|
||||
{ { "^%[.-%]" }, "keyword2" },
|
||||
{ { "%s%[.-%]" }, "keyword2" },
|
||||
{ { "=" }, "operator" },
|
||||
{ { "https?://[%w_.~!*:@&+$/?%%#-]-%w[-.%w]*%.%w%w%w?%w?:?%d*/?[%w_.~!*:@&+$/?%%#=-]*" },
|
||||
{ { "https?://[%w_.~!*:@&+$/?%%#-]-%w[-.%w]*%.%w%w%w?%w?:?%d*/?[%w_.~!*:@&+$/"
|
||||
"?%%#=-]*" },
|
||||
"link" },
|
||||
{ { "[a-z]+" }, "symbol" } },
|
||||
{ { "true", "literal" }, { "false", "literal" } },
|
||||
@@ -1875,23 +1876,32 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() {
|
||||
add( { "YAML",
|
||||
{ "%.yml$", "%.yaml$" },
|
||||
{
|
||||
{ { "^#.-\n" }, "comment" },
|
||||
{ { "%s#.-\n" }, "comment" },
|
||||
{ { "#", "\n" }, "comment" },
|
||||
{ { "\"", "\"", "\\" }, "string" },
|
||||
{ { "'", "'", "\\" }, "string" },
|
||||
{ { "!!str", "\n", "\\" }, "string" },
|
||||
{ { "%s-%-%s+.*\n" }, "keyword2" },
|
||||
{ { "%s+[%w%s-_]+:%s+" }, "keyword" },
|
||||
{ { "^[%w%s-_]+:%s+" }, "keyword" },
|
||||
{ { "%f[%S]%-?0x%x+" }, "number" },
|
||||
{ { "%f[%S]%-?%d+[%d%.eE]*f?" }, "number" },
|
||||
{ { "%f[%S]%-?%.?%d+f?" }, "number" },
|
||||
{ { "!!float", "\n", "\\" }, "number" },
|
||||
{ { "https?://[%w_.~!*:@&+$/?%%#-]-%w[-.%w]*%.%w%w%w?%w?:?%d*/?[%w_.~!*:@&+$/?%%#=-]*" },
|
||||
{ { "%-?%.inf" }, "number" },
|
||||
{ { "%.NaN" }, "number" },
|
||||
{ { "(%&)(%g+)" }, { "keyword", "literal", "" } },
|
||||
{ { "!%g+" }, "keyword" },
|
||||
{ { "<<" }, "literal" },
|
||||
{ { "https?://[%w_.~!*:@&+$/?%%#-]-%w[-.%w]*%.%w%w%w?%w?:?%d*/?[%w_.~!*:@&+$/"
|
||||
"?%%#=-]*" },
|
||||
"link" },
|
||||
{ { "%-%-%-" }, "literal" },
|
||||
{ { "([%s]%*)([%w%d_]+)" }, { "keyword", "keyword", "keyword2" } },
|
||||
{ { "(%*)([%w%d_]+)" }, { "keyword", "keyword", "literal" } },
|
||||
{ { "([%[%{])(%s*[%w%d]+%g+%s*)(:%s)" },
|
||||
{ "keyword", "operator", "operator", "keyword" } },
|
||||
{ { "([%s][%w%d]+%g+%s*)(:%s)" }, { "keyword", "keyword", "operator" } },
|
||||
{ { "([%w%d]+%g+%s*)(:%s)" }, { "keyword", "keyword", "operator" } },
|
||||
{ { "0%d+" }, "number" },
|
||||
{ { "0x%x+" }, "number" },
|
||||
{ { "[%+%-]?%d+[,%.eE:%+%d]*%d+" }, "number" },
|
||||
{ { "[%*%|%!>%%]" }, "keyword" },
|
||||
{ { "[%-:%?%*%{%}%[%]]" }, "operator" },
|
||||
{ { "([%d%a_][%g_]*)([%]%},])" }, { "string", "operator", "operator" } },
|
||||
{ { "[%d%a$/_][%g_]*" }, "string" },
|
||||
},
|
||||
{},
|
||||
{ { "true", "number" }, { "false", "number" }, { "y", "number" }, { "n", "number" } },
|
||||
"#" } );
|
||||
|
||||
// Swift
|
||||
|
||||
@@ -6,9 +6,10 @@ using namespace EE::System;
|
||||
|
||||
namespace EE { namespace UI { namespace Doc {
|
||||
|
||||
// This tokenizer is a direct conversion to C++ from the lite (https://github.com/rxi/lite)
|
||||
// This tokenizer was a direct conversion to C++ from the lite (https://github.com/rxi/lite)
|
||||
// tokenizer. This allows eepp to support the same color schemes and syntax definitions from
|
||||
// lite. Making much easier to implement a complete code editor.
|
||||
// lite. Making much easier to implement a complete code editor. Currently some improvements
|
||||
// has been made. It's still compatible with lite tokenizer.
|
||||
|
||||
#define MAX_TOKEN_SIZE ( 512 )
|
||||
|
||||
|
||||
@@ -2277,9 +2277,9 @@ void UICodeEditor::drawWordMatch( const String& text, const std::pair<int, int>&
|
||||
primitives.setForceDraw( true );
|
||||
}
|
||||
|
||||
void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Float& fontSize,
|
||||
void UICodeEditor::drawLineText( const Int64& line, Vector2f position, const Float& fontSize,
|
||||
const Float& lineHeight ) {
|
||||
auto& tokens = mHighlighter.getLine( index );
|
||||
auto& tokens = mHighlighter.getLine( line );
|
||||
Primitives primitives;
|
||||
Int64 curChar = 0;
|
||||
Int64 maxWidth = eeceil( mSize.getWidth() / getGlyphWidth() + 1 );
|
||||
@@ -2291,17 +2291,17 @@ void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Fl
|
||||
Int64 curCharsWidth = text.size();
|
||||
Int64 curPositionChar = eefloor( mScroll.x / getGlyphWidth() );
|
||||
Float curMaxPositionChar = curPositionChar + maxWidth;
|
||||
Text line( "", mFont, fontSize );
|
||||
line.setDisableCacheWidth( true );
|
||||
line.setTabWidth( mTabWidth );
|
||||
Text txt( "", mFont, fontSize );
|
||||
txt.setDisableCacheWidth( true );
|
||||
txt.setTabWidth( mTabWidth );
|
||||
const SyntaxColorScheme::Style& style = mColorScheme.getSyntaxStyle( token.type );
|
||||
line.setStyleConfig( mFontStyleConfig );
|
||||
txt.setStyleConfig( mFontStyleConfig );
|
||||
if ( style.style )
|
||||
line.setStyle( style.style );
|
||||
line.setColor( Color( style.color ).blendAlpha( mAlpha ) );
|
||||
txt.setStyle( style.style );
|
||||
txt.setColor( Color( style.color ).blendAlpha( mAlpha ) );
|
||||
|
||||
if ( mHandShown && mLinkPosition.isValid() && mLinkPosition.inSameLine() &&
|
||||
mLinkPosition.start().line() == index ) {
|
||||
mLinkPosition.start().line() == line ) {
|
||||
if ( mLinkPosition.start().column() >= curChar &&
|
||||
mLinkPosition.end().column() <= curChar + curCharsWidth ) {
|
||||
size_t linkPos = text.find( mLink );
|
||||
@@ -2310,7 +2310,7 @@ void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Fl
|
||||
String afterString( text.substr( linkPos + mLink.size() ) );
|
||||
|
||||
Float offset = 0.f;
|
||||
Uint32 lineStyle = line.getStyle();
|
||||
Uint32 lineStyle = txt.getStyle();
|
||||
|
||||
if ( !beforeString.empty() ) {
|
||||
Float beforeWidth = getTextWidth( beforeString );
|
||||
@@ -2320,8 +2320,8 @@ void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Fl
|
||||
primitives.drawRectangle(
|
||||
Rectf( position, Sizef( beforeWidth, lineHeight ) ) );
|
||||
}
|
||||
line.setString( beforeString );
|
||||
line.draw( position.x, position.y );
|
||||
txt.setString( beforeString );
|
||||
txt.draw( position.x, position.y );
|
||||
offset += beforeWidth;
|
||||
}
|
||||
|
||||
@@ -2330,12 +2330,12 @@ void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Fl
|
||||
if ( mColorScheme.hasSyntaxStyle( "link_hover" ) ) {
|
||||
linkStyle = mColorScheme.getSyntaxStyle( "link_hover" );
|
||||
if ( linkStyle.color != Color::Transparent )
|
||||
line.setColor( Color( linkStyle.color ).blendAlpha( mAlpha ) );
|
||||
line.setStyle( linkStyle.style );
|
||||
txt.setColor( Color( linkStyle.color ).blendAlpha( mAlpha ) );
|
||||
txt.setStyle( linkStyle.style );
|
||||
} else {
|
||||
line.setStyle( ( lineStyle & Text::Underlined )
|
||||
? ( lineStyle | Text::Bold )
|
||||
: ( lineStyle | Text::Underlined ) );
|
||||
txt.setStyle( ( lineStyle & Text::Underlined )
|
||||
? ( lineStyle | Text::Bold )
|
||||
: ( lineStyle | Text::Underlined ) );
|
||||
}
|
||||
|
||||
Float linkWidth = getTextWidth( mLink );
|
||||
@@ -2346,8 +2346,8 @@ void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Fl
|
||||
Rectf( Vector2f( position.x + offset, position.y ),
|
||||
Sizef( linkWidth, lineHeight ) ) );
|
||||
}
|
||||
line.setString( mLink );
|
||||
line.draw( position.x + offset, position.y );
|
||||
txt.setString( mLink );
|
||||
txt.draw( position.x + offset, position.y );
|
||||
offset += linkWidth;
|
||||
|
||||
if ( !afterString.empty() ) {
|
||||
@@ -2359,10 +2359,10 @@ void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Fl
|
||||
Rectf( Vector2f( position.x + offset, position.y ),
|
||||
Sizef( afterWidth, lineHeight ) ) );
|
||||
}
|
||||
line.setColor( Color( style.color ).blendAlpha( mAlpha ) );
|
||||
line.setStyle( lineStyle );
|
||||
line.setString( afterString );
|
||||
line.draw( position.x + offset, position.y );
|
||||
txt.setColor( Color( style.color ).blendAlpha( mAlpha ) );
|
||||
txt.setStyle( lineStyle );
|
||||
txt.setString( afterString );
|
||||
txt.draw( position.x + offset, position.y );
|
||||
}
|
||||
|
||||
position.x += textWidth;
|
||||
@@ -2385,18 +2385,18 @@ void UICodeEditor::drawLineText( const Int64& index, Vector2f position, const Fl
|
||||
Int64 totalChars = curCharsWidth - start;
|
||||
Int64 end = eemin( totalChars, minimumCharsToCoverScreen );
|
||||
if ( curCharsWidth >= charsToVisible ) {
|
||||
line.setString( text.substr( start, end ) );
|
||||
line.draw( position.x + start * getGlyphWidth(), position.y );
|
||||
txt.setString( text.substr( start, end ) );
|
||||
txt.draw( position.x + start * getGlyphWidth(), position.y );
|
||||
if ( minimumCharsToCoverScreen == end )
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
line.setString( text.substr( 0, eemin( curCharsWidth, maxWidth ) ) );
|
||||
line.draw( position.x, position.y );
|
||||
txt.setString( text.substr( 0, eemin( curCharsWidth, maxWidth ) ) );
|
||||
txt.draw( position.x, position.y );
|
||||
}
|
||||
} else {
|
||||
line.setString( text );
|
||||
line.draw( position.x, position.y );
|
||||
txt.setString( text );
|
||||
txt.draw( position.x, position.y );
|
||||
}
|
||||
} else if ( position.x > mScreenPos.x + mSize.getWidth() ) {
|
||||
break;
|
||||
|
||||
@@ -61,11 +61,11 @@ void UITextEdit::setTheme( UITheme* Theme ) {
|
||||
onThemeLoaded();
|
||||
}
|
||||
|
||||
void UITextEdit::shrinkText( const Float& maxWidth ) {
|
||||
void UITextEdit::wrapText( const Float& maxWidth ) {
|
||||
Text text;
|
||||
text.setStyleConfig( mFontStyleConfig );
|
||||
text.setString( getText() );
|
||||
text.shrinkText( maxWidth );
|
||||
text.wrapText( maxWidth );
|
||||
mDoc->reset();
|
||||
mDoc->textInput( text.getString() );
|
||||
}
|
||||
@@ -78,7 +78,7 @@ void UITextEdit::setText( const String& text ) {
|
||||
mDoc->reset();
|
||||
mDoc->textInput( text );
|
||||
if ( mFlags & UI_WORD_WRAP ) {
|
||||
shrinkText( getViewportWidth( true ) );
|
||||
wrapText( getViewportWidth( true ) );
|
||||
}
|
||||
if ( !hasFocus() ) {
|
||||
mCursorVisible = false;
|
||||
|
||||
@@ -300,7 +300,7 @@ const String& UITextInput::getText() {
|
||||
return UITextView::getText();
|
||||
}
|
||||
|
||||
void UITextInput::shrinkText( const Uint32& ) {}
|
||||
void UITextInput::wrapText( const Uint32& ) {}
|
||||
|
||||
void UITextInput::updateText() {}
|
||||
|
||||
|
||||
@@ -267,16 +267,16 @@ UITextView* UITextView::setSelectionBackColor( const Color& color ) {
|
||||
|
||||
void UITextView::autoShrink() {
|
||||
if ( mFlags & UI_WORD_WRAP ) {
|
||||
shrinkText( mSize.getWidth() );
|
||||
wrapText( mSize.getWidth() );
|
||||
}
|
||||
}
|
||||
|
||||
void UITextView::shrinkText( const Uint32& maxWidth ) {
|
||||
void UITextView::wrapText( const Uint32& maxWidth ) {
|
||||
if ( mFlags & UI_WORD_WRAP ) {
|
||||
mTextCache->setString( mString );
|
||||
}
|
||||
|
||||
mTextCache->shrinkText( maxWidth );
|
||||
mTextCache->wrapText( maxWidth );
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ void UITextView::drawSelection( Text* textCache ) {
|
||||
if ( !mSelPosCache.empty() ) {
|
||||
Primitives P;
|
||||
P.setColor( mFontStyleConfig.FontSelectionBackColor );
|
||||
Float vspace = textCache->getFont()->getFontHeight( textCache->getCharacterSizePx() );
|
||||
Float vspace = textCache->getFont()->getLineSpacing( textCache->getCharacterSizePx() );
|
||||
|
||||
for ( size_t i = 0; i < mSelPosCache.size(); i++ ) {
|
||||
initPos = mSelPosCache[i].initPos;
|
||||
|
||||
@@ -96,7 +96,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
text.setFontSize( 24 );
|
||||
text.setAlign( TEXT_ALIGN_CENTER );
|
||||
text.setString( Txt );
|
||||
text.shrinkText( win->getWidth() - 96 );
|
||||
text.wrapText( win->getWidth() - 96 );
|
||||
|
||||
// Set the font color to a substring of the text
|
||||
// Create a gradient
|
||||
|
||||
@@ -227,6 +227,10 @@ void LinterModule::runLinter( std::shared_ptr<TextDocument> doc, const Linter& l
|
||||
// Log::info( "Linter result:\n%s", data.c_str() );
|
||||
|
||||
std::map<Int64, std::vector<LinterMatch>> matches;
|
||||
size_t totalMatches = 0;
|
||||
size_t totalErrors = 0;
|
||||
size_t totalWarns = 0;
|
||||
size_t totalNotice = 0;
|
||||
|
||||
for ( auto warningPatterm : linter.warningPattern ) {
|
||||
String::replaceAll( warningPatterm, "$FILENAME", path );
|
||||
@@ -244,7 +248,8 @@ void LinterModule::runLinter( std::shared_ptr<TextDocument> doc, const Linter& l
|
||||
String::toLowerInPlace( type );
|
||||
if ( String::startsWith( type, "warn" ) ) {
|
||||
linterMatch.type = LinterType::Warning;
|
||||
} else if ( String::startsWith( type, "notice" ) ) {
|
||||
} else if ( String::startsWith( type, "notice" ) ||
|
||||
String::startsWith( type, "hint" ) ) {
|
||||
linterMatch.type = LinterType::Notice;
|
||||
}
|
||||
}
|
||||
@@ -267,13 +272,29 @@ void LinterModule::runLinter( std::shared_ptr<TextDocument> doc, const Linter& l
|
||||
|
||||
{
|
||||
Lock matchesLock( mMatchesMutex );
|
||||
mMatches[doc.get()] = matches;
|
||||
totalMatches = matches.size();
|
||||
for ( const auto& matchLine : matches ) {
|
||||
for ( const auto& match : matchLine.second ) {
|
||||
switch ( match.type ) {
|
||||
case LinterType::Warning:
|
||||
++totalWarns;
|
||||
case LinterType::Notice:
|
||||
++totalNotice;
|
||||
case LinterType::Error:
|
||||
default:
|
||||
++totalErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
mMatches[doc.get()] = std::move( matches );
|
||||
}
|
||||
|
||||
invalidateEditors( doc.get() );
|
||||
|
||||
Log::info( "LinterModule::runLinter for %s took %.2fms. Found: %d matches.", path.c_str(),
|
||||
clock.getElapsedTime().asMilliseconds(), matches.size() );
|
||||
Log::info( "LinterModule::runLinter for %s took %.2fms. Found: %d matches. Errors: %d, "
|
||||
"Warnings: %d, Notices: %d.",
|
||||
path.c_str(), clock.getElapsedTime().asMilliseconds(), totalMatches, totalErrors,
|
||||
totalWarns, totalNotice );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user