Skip to content

Commit

Permalink
Merge branch 'develop' into debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Dec 20, 2024
2 parents ecf0bf1 + c4daa30 commit 48f7d64
Show file tree
Hide file tree
Showing 17 changed files with 411 additions and 210 deletions.
10 changes: 5 additions & 5 deletions bin/assets/plugins/formatters.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
},
{
"language": "rust",
"file_patterns": ["%.rs"],
"file_patterns": ["%.rs$"],
"command": "rustfmt --emit stdout --color never $FILENAME",
"url": "https://rust-lang.github.io/rustfmt/"
},
{
"language": "go",
"file_patterns": ["%.go"],
"file_patterns": ["%.go$"],
"command": "gopls format $FILENAME",
"url": "https://pkg.go.dev/golang.org/x/tools/gopls"
},
Expand All @@ -53,21 +53,21 @@
},
{
"language": [ "xml" ],
"file_patterns": ["%.xml"],
"file_patterns": ["%.xml$"],
"command": "xml",
"type": "native",
"url": "#native"
},
{
"language": "css",
"file_patterns": ["%.css"],
"file_patterns": ["%.css$"],
"command": "css",
"type": "native",
"url": "#native"
},
{
"language": "zig",
"file_patterns": ["%.zig"],
"file_patterns": ["%.zig$"],
"command": "zig fmt $FILENAME",
"type": "inplace",
"url": "https://ziglang.org"
Expand Down
18 changes: 9 additions & 9 deletions bin/assets/plugins/lspclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,50 +132,50 @@
"name": "lua-language-server",
"url": "https://github.com/sumneko/lua-language-server",
"command": "lua-language-server",
"file_patterns": ["%.lua"]
"file_patterns": ["%.lua$"]
},
{
"language": "kotlin",
"name": "kotlin-language-server",
"url": "https://github.com/fwcd/kotlin-language-server",
"command": "kotlin-language-server",
"file_patterns": ["%.kt"]
"file_patterns": ["%.kt$"]
},
{
"language": "nim",
"name": "nimlsp",
"url": "https://github.com/PMunch/nimlsp",
"command": "nimlsp",
"file_patterns": ["%.nim"]
"file_patterns": ["%.nim$"]
},
{
"language": "ruby",
"name": "solargraph",
"url": "https://solargraph.org",
"command": "solargraph stdio",
"rootIndicationFileNames": ["Gemfile", "Gemfile.lock", "gems.rb", "gems.lock", "Rakefile"],
"file_patterns": ["%.rb"]
"file_patterns": ["%.rb$"]
},
{
"language": "yaml",
"name": "yaml-language-server",
"url": "https://github.com/redhat-developer/yaml-language-server",
"command": "yaml-language-server --stdio",
"file_patterns": ["%.yaml", "%.yml"]
"file_patterns": ["%.yaml$", "%.yml$"]
},
{
"language": "dart",
"name": "dart language-server",
"url": "https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/tool/lsp_spec",
"command": "dart language-server --client-id ecode",
"file_patterns": ["%.dart"]
"file_patterns": ["%.dart$"]
},
{
"language": "shellscript",
"name": "bash-language-server",
"url": "https://github.com/bash-lsp/bash-language-server",
"command": "bash-language-server start",
"file_patterns": ["%.sh", "%.bash"]
"file_patterns": ["%.sh$", "%.bash$"]
},
{
"language": "html",
Expand Down Expand Up @@ -317,7 +317,7 @@
"name": "glsl_analyzer",
"url": "https://github.com/nolanderc/glsl_analyzer",
"command": "glsl_analyzer",
"file_patterns": ["%.glsl$", "%.frag$", "%.vert$", "%.fs$", "%.vs$", "%.tesc", "%.tese"]
"file_patterns": ["%.glsl$", "%.frag$", "%.vert$", "%.fs$", "%.vs$", "%.tesc$", "%.tese$"]
},
{
"language": "vala",
Expand Down Expand Up @@ -366,7 +366,7 @@
"name": "LanguageServer.jl",
"url": "https://github.com/julia-vscode/LanguageServer.jl",
"command": "julia --project=\"$HOME/.julia/packages/LanguageServer/Fwm1f/src/LanguageServer.jl\" -e \"using LanguageServer; runserver()\"",
"file_patterns": ["%.jl"]
"file_patterns": ["%.jl$"]
},
{
"language": "fortran",
Expand Down
174 changes: 33 additions & 141 deletions include/eepp/ui/doc/textrange.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
#define EE_UI_DOC_TEXTRANGE_HPP

#include <algorithm>
#include <eepp/core/debug.hpp>
#include <eepp/ui/doc/textposition.hpp>

namespace EE { namespace UI { namespace Doc {

class EE_API TextRange {
public:
TextRange() {}
TextRange( const TextPosition& start, const TextPosition& end ) :
mStart( start ), mEnd( end ) {}
TextRange();

bool isValid() const { return mStart.isValid() && mEnd.isValid(); }
TextRange( const TextPosition& start, const TextPosition& end );

void clear() {
mStart = {};
mEnd = {};
}
bool isValid() const;

void clear();

TextPosition& start() { return mStart; }

Expand All @@ -28,14 +24,9 @@ class EE_API TextRange {

const TextPosition& end() const { return mEnd; }

TextRange normalized() const { return TextRange( normalizedStart(), normalizedEnd() ); }
TextRange normalized() const;

TextRange& normalize() {
auto normalize( normalized() );
mStart = normalize.start();
mEnd = normalize.end();
return *this;
}
TextRange& normalize();

void reverse() { std::swap( mEnd, mStart ); }

Expand All @@ -45,10 +36,7 @@ class EE_API TextRange {

void setEnd( const TextPosition& position ) { mEnd = position; }

void set( const TextPosition& start, const TextPosition& end ) {
mStart = start;
mEnd = end;
}
void set( const TextPosition& start, const TextPosition& end );

bool operator==( const TextRange& other ) const {
return mStart == other.mStart && mEnd == other.mEnd;
Expand Down Expand Up @@ -90,21 +78,9 @@ class EE_API TextRange {
return TextRange( mStart - other.mStart, mEnd - other.mEnd );
}

bool contains( const TextPosition& position ) const {
if ( !( position.line() > mStart.line() ||
( position.line() == mStart.line() && position.column() >= mStart.column() ) ) )
return false;
if ( !( position.line() < mEnd.line() ||
( position.line() == mEnd.line() && position.column() <= mEnd.column() ) ) )
return false;
return true;
}
bool contains( const TextPosition& position ) const;

bool intersectsLineRange( const TextRange& range ) const {
eeASSERT( range.isNormalized() );
return mStart.line() <= static_cast<Int64>( range.end().line() ) &&
static_cast<Int64>( range.start().line() ) <= mEnd.line();
}
bool intersectsLineRange( const TextRange& range ) const;

template <typename T> bool intersectsLineRange( T fromLine, T toLine ) const {
return mStart.line() <= static_cast<Int64>( toLine ) &&
Expand All @@ -116,44 +92,25 @@ class EE_API TextRange {
static_cast<Int64>( range.first ) <= mEnd.line();
}

bool containsLine( const Int64& line ) const {
return line >= mStart.line() && line <= mEnd.line();
}
bool containsLine( const Int64& line ) const;

bool contains( const TextRange& range ) const {
return range.start() >= start() && range.end() <= end();
}
bool contains( const TextRange& range ) const;

bool intersects( const TextRange& range ) const;

TextRange merge( const TextRange& range ) const;

bool hasSelection() const { return isValid() && mStart != mEnd; }

bool inSameLine() const { return isValid() && mStart.line() == mEnd.line(); }

Int64 height() const {
if ( mEnd.line() > mStart.line() )
return mEnd.line() - mStart.line() + 1;
return mStart.line() - mStart.line() + 1;
}
Int64 height() const;

Int64 length() const {
if ( !inSameLine() )
return 0;
if ( mEnd.column() > mStart.column() )
return mEnd.column() - mStart.column();
return mStart.column() - mEnd.column();
}
Int64 length() const;

std::string toString() const {
return String::format( "%s - %s", mStart.toString().c_str(), mEnd.toString().c_str() );
}
std::string toString() const;

static TextRange fromString( const std::string& range ) {
auto split = String::split( range, "-" );
if ( split.size() == 2 ) {
return { TextPosition::fromString( String::trim( split[0] ) ),
TextPosition::fromString( String::trim( split[1] ) ) };
}
return {};
}
static TextRange fromString( const std::string& range );

bool isNormalized() const { return mStart <= mEnd; }

Expand All @@ -168,96 +125,31 @@ class EE_API TextRange {

class EE_API TextRanges : public std::vector<TextRange> {
public:
TextRanges() {}
TextRanges();

TextRanges( const std::vector<TextRange>& ranges ) : std::vector<TextRange>( ranges ) {}
TextRanges( const std::vector<TextRange>& ranges );

TextRanges( const TextRange& ranges ) : std::vector<TextRange>( { ranges } ) {}
TextRanges( const TextRange& ranges );

bool isSorted() const { return mIsSorted; }
bool isSorted() const;

bool isValid() const {
for ( const auto& selection : *this ) {
if ( !selection.isValid() )
return false;
}
return true;
}

bool exists( const TextRange& range ) const {
if ( !mIsSorted )
return std::find( begin(), end(), range ) != end();
return std::binary_search( begin(), end(), range );
}
bool isValid() const;

size_t findIndex( const TextRange& range ) const {
if ( !mIsSorted ) {
auto it = std::find( begin(), end(), range );
return it != end() ? std::distance( begin(), it ) : static_cast<size_t>( -1 );
} else {
auto it = std::lower_bound( begin(), end(), range );
return ( it != end() && *it == range ) ? std::distance( begin(), it )
: static_cast<size_t>( -1 );
}
}
bool exists( const TextRange& range ) const;

bool hasSelection() const {
for ( const auto& r : *this )
if ( r.hasSelection() )
return true;
return false;
}

void sort() {
std::sort( begin(), end() );
setSorted();
}
size_t findIndex( const TextRange& range ) const;

void setSorted() { mIsSorted = true; }
bool hasSelection() const;

bool merge() {
if ( size() <= 1 )
return false;
void sort();

if ( !mIsSorted )
sort();
void setSorted();

auto itUnique = std::unique(
begin(), end(), []( const TextRange& a, const TextRange& b ) { return a == b; } );
bool merge();

bool merged = itUnique != end();
erase( itUnique, end() );
std::string toString() const;

auto it = begin();
while ( it != end() ) {
auto next = std::next( it );
while ( next != end() && it != end() && next->contains( *it ) ) {
erase( it );
it = std::prev( next );
}
it = next;
}

return merged;
}

std::string toString() const {
std::string str;
for ( size_t i = 0; i < size(); ++i ) {
str += ( *this )[i].toString();
if ( i != size() - 1 )
str += ";";
}
return str;
}

static TextRanges fromString( const std::string& str ) {
auto rangesStr = String::split( str, ';' );
TextRanges ranges;
for ( const auto& rangeStr : rangesStr )
ranges.emplace_back( TextRange::fromString( rangeStr ) );
return ranges;
}
static TextRanges fromString( const std::string& str );

protected:
bool mIsSorted{ false };
Expand Down
1 change: 1 addition & 0 deletions projects/linux/ee.files
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@
../../src/eepp/ui/doc/syntaxtokenizer.cpp
../../src/eepp/ui/doc/textdocument.cpp
../../src/eepp/ui/doc/textformat.cpp
../../src/eepp/ui/doc/textrange.cpp
../../src/eepp/ui/doc/textundostack.cpp
../../src/eepp/ui/doc/documentview.cpp
../../src/eepp/ui/keyboardshortcut.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/eepp/ui/doc/languages/c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void addC() {
auto& sd = SyntaxDefinitionManager::instance()->add(

{ "C",
{ "%.c$", "%.C", "%.h$", "%.icc" },
{ "%.c$", "%.C$", "%.h$", "%.icc$" },
{
{ { "//.-\n" }, "comment" },
{ { "/%*", "%*/" }, "comment" },
Expand Down
2 changes: 1 addition & 1 deletion src/eepp/ui/doc/languages/html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void addHTML() {
->add(

{ "HTML",
{ "%.[mp]?html?$", "%.handlebars" },
{ "%.[mp]?html?$", "%.handlebars$" },
{
{ { "<%s*[sS][cC][rR][iI][pP][tT]%s+[tT][yY][pP][eE]%s*=%s*['\"]%a+/"
"[jJ][aA][vV][aA][sS][cC][rR][iI][pP][tT]['\"]%s*>",
Expand Down
2 changes: 1 addition & 1 deletion src/eepp/ui/doc/languages/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void addJSON() {
auto& sd = SyntaxDefinitionManager::instance()->add(

{ "JSON",
{ "%.json$", "%.cson$", "%.webmanifest" },
{ "%.json$", "%.cson$", "%.webmanifest$" },
{
{ { "(%b\"\")(:)" }, { "normal", "keyword", "operator" } },
{ { "\"", "\"", "\\" }, "string" },
Expand Down
Loading

0 comments on commit 48f7d64

Please sign in to comment.