Giter Club home page Giter Club logo

edbee-lib's Introduction

edbee-lib

Build Status Coverity Scan Build Status

Edbee is a Qt based Editor Component. It supports Multiple-carets, Textmate Scoping/Grammar and Highlighting support.

The base class of edbee is a QWidget, it has been written from scratch and is not based on the Qt default editor components.

Screenshot of the example application

The main website for edbee is at http://edbee.net/ You can find the generated documentation at http://docs.edbee.net/

This repository is a clean extraction of the previous edbee monolithical repository. This library doesn't contain any data files. Using it should become as easy as the following example:

#include "edbee/edbee.h"
edbee::TextEditorWidget* widget =  new edbee::TextEditorWidget();

Unfortunately we're not at this point yet. Currently the edbee library will not function without loading a default keymap file.

Examples

Using the component is pretty easy. First you must setup the edbee environment. This process is required to make the library know the location of the settings files:

#include "edbee/edbee.h"

// get the edbee instance
edbee::Edbee* tm = edbee::Edbee::instance();

// configure your paths
tm->setKeyMapPath( "location/of/your/keymap/");
tm->setGrammarPath(  "location/of/your/syntaxfiles/" );
tm->setThemePath( "location/of/your/themes/" );

// initialize the library
tm->init();

// by registering a shutdown function on application exit you don't have to destroy the edbee
// resources yourself. It will result in a clean shutdown
tm->autoShutDownOnAppExit();

After that you're ready to go. You can create a widget like this:

edbee::TextEditorWidget* widget =  new edbee::TextEditorWidget();

Of course it would also be nice to fill the editor with a file. you can use the included serializer for this.

#include "edbee/io/textdocumentserializer.h"
#include "edbee/texteditorwidget.h"

edbee::TextEditorWidget* widget =  new edbee::TextEditorWidget();
edbee::TextDocumentSerializer serializer( widget->textDocument() );
QFile file( QStringLiteral("your-filename.rb") );
if( !serializer.load( &file ) ) {
    QMessageBox::warning(this, tr("Error opening file"), tr("Error opening file!\n%1").arg(serializer.errorString()) );
}

After loading the textfile it is nice to detect the grammar/language of this file. The edbee library uses an extension based file-type detection. Of course you can also plugin your own.

#include "edbee/edbee.h"
#include "edbee/models/textdocument.h"
#include "edbee/models/textgrammar.h"
#include "edbee/texteditorwidget.h"

TextGrammarManager* grammarManager = edbee::Edbee::instance()->grammarManager();
TextGrammar* grammar = grammarManager->detectGrammarWithFilename( "a-ruby-file.rb" );
widget->textDocument()->setLanguagGrammar( grammar );

Auto Complete

Edbee supports autocomplete. Currently it's very limited, but the groundwork has been done for supporting more advanced autocompletions.

Auto Complete works by querying autocomplete providers (TextAutoCompleteProvider). It has a TextAutoCompleteProviderList on TextDocument level and globally via the Edbee::instance() level.

Currently only the StringTextAutoCompleteProvider is implemented. You can add an autocomplete list on the document-level and the edbeel level.

Ideas for the future

  • It should use Fuzzy search
  • Words should get a priority and should be sorted witht this priority
  • Providers based on existing words in the current TextDocument. (This requires some smart non-ui-blocking word-list building)
  • Provider based on the current scope. Keywords depending on active TextDocumentScopes (language specific/context specific lists)
  • Supporting textmate/sublime like snippets (with tab stops)

Currently you can set the keywords List like this:

#include "edbee/models/textautocompleteprovider.h"

StringTextAutoCompleteProvider* provider = new StringTextAutoCompleteProvider();
provider->add("const");
provider->add("class");
provider->add("compare");
// etc ...

// to add it Locally (specific to the given document)
textDocument->autoCompleteProviderList()->giveProvider(provider);

// to add it Globally:
Edbee::instance()->autoCompleteProviderList()->giveProvider(provider);

Known Issues

  • items aren't sorted yet (this should be priority sort)
  • Currently the position of the autcomplete window isnt' very smart. (especially at the bottom and side of the document)
  • Backspace hides the window

Tips and Tricks

Object-name conflicts

When you're QT projects uses for example util.cpp you can get an object-file collission. (Makefile: Warning: overriding commands for target util.o). A workaround for this is appending the following lines in your (OBJECTS_DIR is optional, but prevents a warning when running QMAKE)

CONFIG += object_parallel_to_source in your .pro file
OBJECTS_DIR = objects

Known Issues and Missing Features

  • The editor doesn't support word-wrapping. (yet)
  • It has issues with long lines. The cause of this is the nature of QTextLayout and the support of variable font sizes. In the future this can be fixed for monospaced fonts.
  • Optimalisations for better render support and background calculate/paint-ahead functionality
  • I really want to build in scripting support, for extending the editor with plugins.

Contributing

You can contribute via github

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Of course you can also contribute by contacting me via twitter @gamecreature or drop me a message via the email-address supplied at https://github.com/gamecreature

Issues?

Though we have our own issue-tracker at ( http://issues.edbee.net/ ), you can report your problems via the github issue tracker or send me a message https://github.com/gamecreature

edbee-lib's People

Contributors

brupelo avatar dicene avatar emoon avatar fscheel avatar gamecreature avatar keneanung avatar konijnendijk avatar sebcaux avatar slysven avatar vadi2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

edbee-lib's Issues

Is Onigmo necessary or would Oniguruma also work?

For those not in the know k-takata/Onigmo is a fork of kkos/oniguruma. However the latter is more likely to be available in GNU/Linux distributions (and is in Cygwin) so using it instead will make it easier to use a "system" version rather than having to include it in this (and other projects such as the one I code for) using this library... 😜

Special keys can not be inserted on french keyboards

Hi, I have found a very embarrasing problem... On my french keyboard it is impossible to insert char like : ~#{[|\^@]} . To insert theses chars, I need to press Alt Gr key that corresponding to Alt + Ctrl

To fix this, I modify the specialKey in TextEditorComponent::keyPressEvent :

    bool specialKey = (modifiers&(Qt::MetaModifier|Qt::ControlModifier))
            && ((modifiers!=(Qt::AltModifier|Qt::ControlModifier)) || text.at(0).isUpper());

I don't know if it is the right way.

Add Coverity Badge?

Following the resolution of #35 - I guess it should be possible to add a badge for Coverity to the README.md file?

Onig issue CLANG c++11 project (with direct .pri include) failed linkage

Including edbee-lib.pri directly failes compilation/linkage on CLANG c++11 Mac OS X.

It results in the following message:

Undefined symbols for architecture x86_64:
  "_OnigEncodingShift_JIS", referenced from:
      _re_mbcinit in reggnu.o
      _reg_set_encoding in regposix.o

Cause

In onigmo enc/shift_jis.c is #included by enc/windows_31j.c but with a special define. Which builds enc/shift_jis.c differently.

Somehow cmake seams to optimize and doesn't parse the .c file again. So it never builds the symbol as shown above

Workaround

Do not include a '.c' file and rename it to a .h file.

  • rename enc/shift_jis.c to enc/shift_jis.h
  • create a new enc/shift_jis.c with the following content:
#include "shift_jis.h"
  • change enc/windows_31j.c the included 'shift_jis.c' to 'shift_jis.h'
#define ENC_CP932
#include "shift_jis.h"

// .. etc. .

See more details at: k-takata/Onigmo#88

I hope the onigmo project changes this implementation. If not (an till that time) I need another workaround..

A solution is to not link the enc/windows_31j.c encoding...

Ctrl-Insert/Shift-Insert doesnt work as they should.

Hi,
In ancient ages, windows copy/paste was ctrl-insert / shift-insert.
and all windows programs support them.
can you implement them too?

Copy = Ctrl-C = Ctrl-Insert
Paste = Ctrl-V = Shift-Insert

Thanks in advance

edbee corrupts when setting a reloaded theme

I'm downloading new themes from the web and would like them refreshed in edbee, so I'm calling themeManager->readThemeFile() and config->setThemeName() again. It works fine on the first go but the second time this is done, edbee painting stuffs up and eventually crashes:

peek 2017-06-09 21-31

Any idea how I'm misusing the API? The code to load the themes is here and to set the theme is the next slot definition after.

edbee-lib fails to compile on Windows

Since updating onig in commit f04111f, the windows builds fail for qmake and gcc. The prepared cmake compilation and clang were not tested.

The reason seems to be that the windows version of config.h is not correctly included. We managed to work around this issue by adding the following to the config.h file

#if _WIN32
  #include "win32/config.h"
#else
// ...
#endif

I'm not sure if that's a correct solution or what would be preferred, so I'll leave this as an issue.

Langserver client support

It would be really awesome if edbee supported the langserver - I've seen it in use in vscode when working with typescript and it is a real boost to productivity and coding pleasure!

How to disable shadows?

Sublime uses shadows on elements that don't have distinct borders, like the minimap - but it doesn't use them on elements that do, like scrollbars. Edbee however uses them on scrollbars as well which is a little over the top for me - how can I disable the shadows?

config.h and confugure (and possibly config.h.in) should NOT be tracked / included by

These files are both ones that are/can be generated at build time and their contents will thus vary depending on the target platform - therefore tracking them will throw up issues when they are regenerated and do not then match the originals included in the repository. This is noticeable after the fix provided by #48 as that now (correctly) calls the Onigmo configure file and the resulting config.h will be build target dependent and if the git repository copy is from a different bitness platform compared to that where the library is being used it will get changed (on *nix at least) which will then show up as a modification tracked by Git when it should be .gitignore d instead (IMHO).

Request for conversion of QString("raw string") to QStringLiteral() or tr() methods

Following on from #54 may I ask if it is possible to go through the whole edbee-lib library and convert all the uses of QString("some string possibly with %1 or more variable argument replacement").arg(1) to use either the:

  • QStringLiteral(...) form if the string is used internally and not user visible
  • tr(...) form if it will be user visible and require translation for use in non English(American) locales

Where a non-user visible constant QString is used as an argument to a function/method where a QLatin1String is a valid argument type the alternative QLatin1String(...) is also viable but it does not support the %1-%9 type variable (positional) replacement arguments that QStringLiteral(...) does.

Ideally for the second type above if the string is a form where plurals are significant e.g. "You have just deleted X paragraph(s)." it would be best if the %n form is used, i.e.:

tr("You have just deleted %n paragraph(s).", "", variableContainingValueForX)

I am requesting this because I am working on several aspects of I18n for the Mudlet project and in the near future I wish to add (run-time) GUI language selection (i.e. the user interface will be changeable to use another language) and part of that will use the Qt system for doing that which uses QObject::tr(); QCoreApplication::translate() or QApplication::translate() in C++ code to provide previously created translated versions of the (presumably "EN-us" or English{American}) source code strings. Obviously it would be beneficial if the editor can also support such a language change {ideally it will respond to receipt of QEvent::LanguageChange events to recreate any affected persistent texts - by regenerated them by reusing tr(...) but for strings that are frequently changed anyway e.g. status-lines it probably will not need that level of coding and things will work well enough just by using tr(...) each time such a string is modified}.

<aside> This is where #define QT_NO_CAST_FROM_ASCII is useful - if the macro is present in the source code it will cause any QString initialisations from raw strings to fail to compile (the compiler will moan about the constructor being private and thus inaccessible) and allow them to be pin-pointed and "fixed"...</aside>

Rendering refresh error

Best explained with a gif using the latest edbee-app:

peek 2017-06-03 10-57

Text I used with Lua syntax highlighting:

function mudletOlderThan(version)
	-- strip trailing zeros
  local stripped = rex.gsub(version, [[(\.0+)+$]], ''):split(.)
	display(stripped)
end

mudletOlderThan("2.5.10.4159")
mudletOlderThan("1.0.0")
mudletOlderThan("0.5")
mudletOlderThan("0.4.1")
mudletOlderThan("1")
mudletOlderThan("1.1")
mudletOlderThan("0.0.0")
mudletOlderThan("2.5.0")
mudletOlderThan("2")
mudletOlderThan("0.0")
mudletOlderThan("2.5.10")
mudletOlderThan("10.5")
mudletOlderThan("1.25.4")
mudletOlderThan("1.2.15")

Edbee crashes when you cut/copy with nothing selected (linux only)

Right-click, copy, crash:

1  QInternalMimeData::formatsHelper(QMimeData const *)                                    0x7ffff6e6f091 
2  ??                                                                                     0x7ffff075ee8e 
3  ??                                                                                     0x7ffff075fada 
4  QXcbConnection::handleXcbEvent(xcb_generic_event_t *)                                  0x7ffff07671de 
5  QXcbConnection::processXcbEvents()                                                     0x7ffff0768e63 
6  QObject::event(QEvent *)                                                               0x7ffff68eda9a 
7  QApplicationPrivate::notify_helper(QObject *, QEvent *)                                0x7ffff76b4f3c 
8  QApplication::notify(QObject *, QEvent *)                                              0x7ffff76b92a0 
9  QCoreApplication::notifyInternal2(QObject *, QEvent *)                                 0x7ffff68c3720 
10 QCoreApplicationPrivate::sendPostedEvents(QObject *, int, QThreadData *)               0x7ffff68c5f13 
11 ??                                                                                     0x7ffff6912b13 
12 g_main_context_dispatch                                                                0x7ffff4eab197 
13 ??                                                                                     0x7ffff4eab3f0 
14 g_main_context_iteration                                                               0x7ffff4eab49c 
15 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)             0x7ffff6912f07 
16 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)                                0x7ffff68c176a 
17 QCoreApplication::exec()                                                               0x7ffff68c95fd 
18 main                                                                       main.cpp 39 0x416026       

Perhaps cut/copy actions could be disabled if there is nothing selected? That would be more intuitive for the user as well.

Library can't be compiled on Linux

I was trying to compile the library using the .pro file located at the project's root directory. I am running Linux 3.13 and using GCC 4.8.2. After running make, I get the following error (lineending.h):

edbee/util/lineending.h:34:24: error: expected unqualified-id before numeric constant
     static LineEnding* unix() { return get( Unix ); }
                        ^
In file included from edbee/util/lineending.cpp:8:0:
edbee/util/lineending.h:34:22: error: expected ‘;’ at end of member declaration
     static LineEnding* unix() { return get( Unix ); }
                      ^
edbee/util/lineending.h:34:24: error: expected unqualified-id before numeric constant
     static LineEnding* unix() { return get( Unix ); }
                        ^
Makefile:2665: recipe for target 'lineending.o' failed

I slightly edited the lineending.h file, and switched to clang++. I got a more helpful error message:

edbee/util/lineending.h:34:24: error: expected member name or ';' after
      declaration specifiers
    static LineEnding *unix() { return get( Unix ); }
    ~~~~~~~~~~~~~~~~~  ^
<built-in>:156:14: note: expanded from here
#define unix 1
             ^

The problem: GCC and Clang define 'unix' to 1 by default (more information here), so it is recommended to use one of the standards (c++11 for example) when compiling.

There are various ways of fixing the problem: renaming the 'unix' function, adding c++11 to the CONFIG variable on the edbee-lib.pro project file, or using #undef to undefine the macro. I think any of the first two would better than the latter.

How to do column selection?

The multiple caret selection through ctrl+click works pretty awesome! I can't figure out how to do column selection though which is something I find really handy for editing blocks of text. Is it possible?

Coverity scan issues

We make use of https://scan.coverity.com (you could set it up for edbee as well), and after running Mudlet through it with edbee integrated, Coverity complained a whole lot. We'll flag them as 3rdparty, but I figure it's useful to report all the issues:

** CID 1446907:  Uninitialized members  (UNINIT_CTOR)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/regexp.cpp: 101 in edbee::OnigRegExpEngine::OnigRegExpEngine(const QString &, bool, edbee::RegExp::Syntax)()


________________________________________________________________________________________________________
*** CID 1446907:  Uninitialized members  (UNINIT_CTOR)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/regexp.cpp: 101 in edbee::OnigRegExpEngine::OnigRegExpEngine(const QString &, bool, edbee::RegExp::Syntax)()
95             OnigOptionType onigOptions = ONIG_OPTION_NONE|ONIG_OPTION_CAPTURE_GROUP;
96             if( !caseSensitive ) { onigOptions = onigOptions | ONIG_OPTION_IGNORECASE;}
97
98             int result = onig_new(&reg_, (OnigUChar*)patternChars, (OnigUChar*)(patternChars + pattern.length()), onigOptions, ONIG_ENCODING_UTF16_LE, ONIG_SYNTAX_DEFAULT, &einfo_);
99             valid_ = result == ONIG_NORMAL;
100             fillError( result );
>>>     CID 1446907:  Uninitialized members  (UNINIT_CTOR)
>>>     Non-static class member "lineRef_" is not initialized in this constructor nor in any functions that it calls.
101         }
102
103
104         /// destructs the regular expression engine
105         virtual ~OnigRegExpEngine()
106         {

** CID 1446906:  Control flow issues  (MISSING_BREAK)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/regexp.cpp: 395 in edbee::RegExp::RegExp(const QString &, bool, edbee::RegExp::Syntax, edbee::RegExp::Engine)()


________________________________________________________________________________________________________
*** CID 1446906:  Control flow issues  (MISSING_BREAK)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/regexp.cpp: 395 in edbee::RegExp::RegExp(const QString &, bool, edbee::RegExp::Syntax, edbee::RegExp::Engine)()
389             case EngineQRegExp:
390                 d_ = new QtRegExpEngine(pattern, caseSensitive, syntax);
391                 break;
392             default:
393                 Q_ASSERT(false);
394                 qlog_warn() << "Invalid engine supplied to RegExp. Falling back to EngineOniguruma";
>>>     CID 1446906:  Control flow issues  (MISSING_BREAK)
>>>     The above case falls through to this one.
395             case EngineOniguruma:
396                 d_ = new OnigRegExpEngine(pattern, caseSensitive, syntax);
397         }
398     }
399
400

** CID 1446905:  Null pointer dereferences  (FORWARD_NULL)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/changes/mergablechangegroup.cpp: 401 in edbee::MergableChangeGroup::toSingleTextChangeTestString()()


________________________________________________________________________________________________________
*** CID 1446905:  Null pointer dereferences  (FORWARD_NULL)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/changes/mergablechangegroup.cpp: 401 in edbee::MergableChangeGroup::toSingleTextChangeTestString()()
395     QString MergableChangeGroup::toSingleTextChangeTestString()
396     {
397         QString result;
398         foreach( AbstractRangedChange* abstractChange, textChangeList_ ) {
399             TextChange* change = dynamic_cast<TextChange*>(abstractChange);
400             if( !result.isEmpty() ) result.append(",");
>>>     CID 1446905:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "change" to "offset", which dereferences it. (The dereference happens because this is a virtual function call.)
401             result.append( QString("%1:%2:%3").arg(change->offset()).arg(change->docLength()).arg(change->storedText()) );
402         }
403         return result;
404     }
405
406

** CID 1446904:  Incorrect expression  (DIVIDE_BY_ZERO)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/simpleprofiler.cpp: 106 in edbee::SimpleProfiler::dumpResults()()


________________________________________________________________________________________________________
*** CID 1446904:  Incorrect expression  (DIVIDE_BY_ZERO)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/simpleprofiler.cpp: 106 in edbee::SimpleProfiler::dumpResults()()
100                 totalCallCount += item->callCount();
101                 totalDurationWitoutChilds += item->durationWithoutChilds();
102             }
103
104             foreach( ProfilerItem* item, items ) {
105                 double durationPercentage = 100.0 * item->duration() / totalDuration;
>>>     CID 1446904:  Incorrect expression  (DIVIDE_BY_ZERO)
>>>     In expression "100. * item->callCount() / totalCallCount", division by expression "totalCallCount" which may be zero has undefined behavior.
106                 double callCountPercentage = 100.0 * item->callCount() / totalCallCount;
107                 double durationWithoutChildsPercenage = 100.0 * item->durationWithoutChilds() / totalDurationWitoutChilds;
108
109                 QString line = QString("%1x(%2%) %3ms(%4%) %5ms(%6%) |  %7:%8 %9")
110                    .arg(item->callCount(),8).arg( callCountPercentage, 6, 'f', 2 )
111                    .arg(item->duration(),6).arg( durationPercentage, 6, 'f', 2 )

** CID 1446902:  Incorrect expression  (DIVIDE_BY_ZERO)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/simpleprofiler.cpp: 107 in edbee::SimpleProfiler::dumpResults()()


________________________________________________________________________________________________________
*** CID 1446902:  Incorrect expression  (DIVIDE_BY_ZERO)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/simpleprofiler.cpp: 107 in edbee::SimpleProfiler::dumpResults()()
101                 totalDurationWitoutChilds += item->durationWithoutChilds();
102             }
103
104             foreach( ProfilerItem* item, items ) {
105                 double durationPercentage = 100.0 * item->duration() / totalDuration;
106                 double callCountPercentage = 100.0 * item->callCount() / totalCallCount;
>>>     CID 1446902:  Incorrect expression  (DIVIDE_BY_ZERO)
>>>     In expression "100. * item->durationWithoutChilds() / totalDurationWitoutChilds", division by expression "totalDurationWitoutChilds" which may be zero has undefined behavior.
107                 double durationWithoutChildsPercenage = 100.0 * item->durationWithoutChilds() / totalDurationWitoutChilds;
108
109                 QString line = QString("%1x(%2%) %3ms(%4%) %5ms(%6%) |  %7:%8 %9")
110                    .arg(item->callCount(),8).arg( callCountPercentage, 6, 'f', 2 )
111                    .arg(item->duration(),6).arg( durationPercentage, 6, 'f', 2 )
112                    .arg(item->durationWithoutChilds(), 6 ).arg( durationWithoutChildsPercenage, 6, 'f', 2 )

** CID 1446901:  Memory - corruptions  (USE_AFTER_FREE)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/mem/debug_new.cpp: 105 in operator delete[] (void *, const char *, int)()


** CID 1446899:  Memory - corruptions  (USE_AFTER_FREE)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/mem/debug_new.cpp: 82 in operator delete (void *, const char *, int)()


________________________________________________________________________________________________________
*** CID 1446899:  Memory - corruptions  (USE_AFTER_FREE)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/mem/debug_new.cpp: 82 in operator delete (void *, const char *, int)()
76     }
77
78
79     /// th delete operator
80     void operator delete (void* p, const char* file, const int line)
81     {
>>>     CID 1446899:  Memory - corruptions  (USE_AFTER_FREE)
>>>     "operator delete" frees "p". [Note: The source code implementation of the function has been overridden by a builtin model.]
82         operator delete(p);
83         debug_free(p, file, line);
84     }
85
86
87     /// the delete operator

** CID 1446898:  Incorrect expression  (NO_EFFECT)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/texttheme.cpp: 311 in edbee::TextThemeStyler::themePointerChanged(const QString &, edbee::TextTheme *, edbee::TextTheme *)()


________________________________________________________________________________________________________
*** CID 1446898:  Incorrect expression  (NO_EFFECT)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/texttheme.cpp: 311 in edbee::TextThemeStyler::themePointerChanged(const QString &, edbee::TextTheme *, edbee::TextTheme *)()
305     void TextThemeStyler::themePointerChanged(const QString& name, TextTheme* oldTheme, TextTheme *newTheme)
306     {
307         if( name == themeName_ ) {
308             themeRef_ = newTheme;
309         } else {
310             if( oldTheme == themeRef_ ) {
>>>     CID 1446898:  Incorrect expression  (NO_EFFECT)
>>>     Comparing an array to null is not useful: ""The old theme is deleted but it's not the same theme name. This shouldn't happen"", since the test will always evaluate as true.
311                 Q_ASSERT(false && "The old theme is deleted but it's not the same theme name. This shouldn't happen");
312                 // If it happens a solution is to set the fallback theme
313             }
314         }
315     }
316

** CID 1446897:  Incorrect expression  (NO_EFFECT)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/commands/newlinecommand.cpp: 178 in edbee::NewlineCommand::execute(edbee::TextEditorController *)()


________________________________________________________________________________________________________
*** CID 1446897:  Incorrect expression  (NO_EFFECT)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/commands/newlinecommand.cpp: 178 in edbee::NewlineCommand::execute(edbee::TextEditorController *)()
172
173             case AddLineAfter:
174                 executeSpecialNewline(controller, true);
175                 break;
176
177             default:
>>>     CID 1446897:  Incorrect expression  (NO_EFFECT)
>>>     Comparing an array to null is not useful: ""Invalid newLineType!"", since the test will always evaluate as true.
178                 Q_ASSERT( false && "Invalid newLineType!");
179         }
180     }
181
182
183     /// Returns the command name

** CID 1446896:  Incorrect expression  (NO_EFFECT)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/textundostack.cpp: 584 in edbee::TextUndoStack::clearRedo(edbee::TextEditorController *)()


________________________________________________________________________________________________________
*** CID 1446896:  Incorrect expression  (NO_EFFECT)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/textundostack.cpp: 584 in edbee::TextUndoStack::clearRedo(edbee::TextEditorController *)()
578         // view specific undo
579         if( controller ) {
580             int idx = changeIndex_;
581             if( controllerIndexMap_.contains(controller) ) {
582                 idx = this->controllerIndexMap_.value(controller);
583             } else {
>>>     CID 1446896:  Incorrect expression  (NO_EFFECT)
>>>     Comparing an array to null is not useful: ""The current controller isn't registered with the undostack!"", since the test will always evaluate as true.
584                 Q_ASSERT(false && "The current controller isn't registered with the undostack!");    // warning view isn't registered!
585             }
586
587             // remove all items from the stack AFTER the given index
588             for( int i=changeList_.size()-1; i >= idx; --i ) {
589                 if( changeList_.at(i)->controllerContext() == controller ) {

** CID 1446895:  Incorrect expression  (DIVIDE_BY_ZERO)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/simpleprofiler.cpp: 105 in edbee::SimpleProfiler::dumpResults()()


________________________________________________________________________________________________________
*** CID 1446895:  Incorrect expression  (DIVIDE_BY_ZERO)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/util/simpleprofiler.cpp: 105 in edbee::SimpleProfiler::dumpResults()()
99                 totalDuration  += item->duration();
100                 totalCallCount += item->callCount();
101                 totalDurationWitoutChilds += item->durationWithoutChilds();
102             }
103
104             foreach( ProfilerItem* item, items ) {
>>>     CID 1446895:  Incorrect expression  (DIVIDE_BY_ZERO)
>>>     In expression "100. * item->duration() / totalDuration", division by expression "totalDuration" which may be zero has undefined behavior.
105                 double durationPercentage = 100.0 * item->duration() / totalDuration;
106                 double callCountPercentage = 100.0 * item->callCount() / totalCallCount;
107                 double durationWithoutChildsPercenage = 100.0 * item->durationWithoutChilds() / totalDurationWitoutChilds;
108
109                 QString line = QString("%1x(%2%) %3ms(%4%) %5ms(%6%) |  %7:%8 %9")
110                    .arg(item->callCount(),8).arg( callCountPercentage, 6, 'f', 2 )

** CID 1446894:  Possible Control flow issues  (DEADCODE)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/io/jsonparser.cpp: 70 in edbee::JsonParser::parse(QIODevice *)()


________________________________________________________________________________________________________
*** CID 1446894:  Possible Control flow issues  (DEADCODE)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/io/jsonparser.cpp: 70 in edbee::JsonParser::parse(QIODevice *)()
64                 return false;
65             }
66         }
67
68         QByteArray bytesIn = device->readAll();
69         bool result = parse( bytesIn );
>>>     CID 1446894:  Possible Control flow issues  (DEADCODE)
>>>     Execution cannot reach this statement: "device->close();".
70         if( opened ) device->close();
71         return result;
72     }
73
74
75     /// opens the given bytes as a json document


** CID 1446891:    (FORWARD_NULL)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/changes/linedatalistchange.cpp: 97 in edbee::LineDataListChange::mergeStoredData(edbee::AbstractRangedChange *)()
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/changes/linedatalistchange.cpp: 106 in edbee::LineDataListChange::mergeStoredData(edbee::AbstractRangedChange *)()


________________________________________________________________________________________________________
*** CID 1446891:    (FORWARD_NULL)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/changes/linedatalistchange.cpp: 97 in edbee::LineDataListChange::mergeStoredData(edbee::AbstractRangedChange *)()
91         LineDataListChange* lineTextChange = dynamic_cast<LineDataListChange*>(change);
92
93         // calculate the new size
94         int newOldListSize = getMergedStoredLength( change);// qlog_info() << "CALCULATED: " << newOldListSize ;
95
96         // no old data, we don't need to store anthing
>>>     CID 1446891:    (FORWARD_NULL)
>>>     Dereferencing null pointer "lineTextChange".
97         if( this->oldListList_ == 0 && lineTextChange->oldListList_ == 0 ) {
98             contentLength_ = newOldListSize;    // also store the content list
99             return;
100         }
101
102         // create the new list
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/changes/linedatalistchange.cpp: 106 in edbee::LineDataListChange::mergeStoredData(edbee::AbstractRangedChange *)()
100         }
101
102         // create the new list
103         TextLineDataList**  newOldListList_ = new TextLineDataList*[newOldListSize];
104
105         // merge the stuff
>>>     CID 1446891:    (FORWARD_NULL)
>>>     Dereferencing null pointer "lineTextChange".
106         mergeStoredDataViaMemcopy( newOldListList_, oldListList_, lineTextChange->oldListList_, change, sizeof(TextLineDataList*) );
107
108         // we need to delete all items that aren't used anymore
109         if( oldListList_ ) {
110             for( int i=0; i<contentLength_; ++i ) {
111                 bool found=false;

** CID 1446890:  Uninitialized members  (UNINIT_CTOR)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/components/texteditorrenderer.cpp: 34 in edbee::TextEditorRenderer::TextEditorRenderer(edbee::TextRenderer *)()


________________________________________________________________________________________________________
*** CID 1446890:  Uninitialized members  (UNINIT_CTOR)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/components/texteditorrenderer.cpp: 34 in edbee::TextEditorRenderer::TextEditorRenderer(edbee::TextRenderer *)()
28         , shadowGradient_(0)
29     {
30         shadowGradient_ = new QLinearGradient( 0, 0, ShadowWidth, 0 );
31         shadowGradient_ ->setColorAt(0, QColor( 0x00, 0x00, 0x00, 0x99 ));
32         shadowGradient_ ->setColorAt(1, QColor( 0x00, 0x00, 0x00, 0x00 ));
33
>>>     CID 1446890:  Uninitialized members  (UNINIT_CTOR)
>>>     Non-static class member "themeRef_" is not initialized in this constructor nor in any functions that it calls.
34     }
35
36     TextEditorRenderer::~TextEditorRenderer()
37     {
38         delete shadowGradient_;
39     }

** CID 1446888:  Uninitialized members  (UNINIT_CTOR)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/textrenderer.cpp: 44 in edbee::TextRenderer::TextRenderer(edbee::TextEditorController *)()


________________________________________________________________________________________________________
*** CID 1446888:  Uninitialized members  (UNINIT_CTOR)
/home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/textrenderer.cpp: 44 in edbee::TextRenderer::TextRenderer(edbee::TextEditorController *)()
38         , totalWidthCache_(0)
39         , textThemeStyler_(0)
40         , clipRectRef_(0)
41     {
42         connect( controller, SIGNAL(textDocumentChanged(edbee::TextDocument*,edbee::TextDocument*)), this, SLOT(textDocumentChanged(edbee::TextDocument*,edbee::TextDocument*)));
43         textThemeStyler_ = new TextThemeStyler( controller );
>>>     CID 1446888:  Uninitialized members  (UNINIT_CTOR)
>>>     Non-static class member "endLine_" is not initialized in this constructor nor in any functions that it calls.
44     }
45
46
47     /// the destructor
48     TextRenderer::~TextRenderer()
49     {

How to clear undo stack of a document?

Clearing the undo stack with ew->textDocument()->textUndoStack()->clear(); makes it consistently crash on clearRedo() afterwards:

#1  0x00007ffff417602a in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff50450fe in QMessageLogger::fatal(char const*, ...) const () from /home/vadi/Programs/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#3  0x00007ffff50408fe in qt_assert(char const*, char const*, int) () from /home/vadi/Programs/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#4  0x00000000009d5df5 in edbee::TextUndoStack::clearRedo (this=0xd5fde60, controller=0xd5fcd40) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/textundostack.cpp:577
#5  0x00000000009d4c33 in edbee::TextUndoStack::giveChange (this=0xd5fde60, change=0x107ce4e0, coalesceId=65617) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/textundostack.cpp:241
#6  0x0000000000a0974b in edbee::CharTextDocument::giveChangeWithoutFilter (this=0xd5f95e0, change=0x107ce4e0, coalesceId=65617) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/chardocument/chartextdocument.cpp:124
#7  0x00000000009d2e34 in edbee::TextDocument::executeAndGiveChange (this=0xd5f95e0, change=0x107ce4e0, coalesceId=65617) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/models/textdocument.cpp:287
#8  0x00000000009e3fb3 in edbee::TextEditorController::changeAndGiveTextSelection (this=0xd5fcd40, rangeSet=0x109c8e50, coalesceId=65617) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/texteditorcontroller.cpp:665
#9  0x00000000009e55b8 in edbee::SelectionCommand::execute (this=0x7fffffffd080, controller=0xd5fcd40) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/commands/selectioncommand.cpp:182
#10 0x00000000009e36bb in edbee::TextEditorController::executeCommand (this=0xd5fcd40, textCommand=0x7fffffffd080) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/texteditorcontroller.cpp:508
#11 0x00000000009e3df8 in edbee::TextEditorController::moveCaretToOffset (this=0xd5fcd40, offset=27, keepAnchors=false) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/texteditorcontroller.cpp:638
#12 0x00000000009e3d85 in edbee::TextEditorController::moveCaretTo (this=0xd5fcd40, line=7, col=0, keepAnchors=false) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/texteditorcontroller.cpp:627
#13 0x00000000009ec901 in edbee::TextEditorComponent::mousePressEvent (this=0xd6012a0, event=0x7fffffffd580) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/components/texteditorcomponent.cpp:382
#14 0x00007ffff63ba321 in QWidget::event(QEvent*) () from /home/vadi/Programs/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#15 0x00000000009ebf4f in edbee::TextEditorComponent::event (this=0xd6012a0, event=0x7fffffffd580) at /home/vadi/Programs/Mudlet/mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/components/texteditorcomponent.cpp:228
#16 0x00007ffff637b4bc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /home/vadi/Programs/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5

Are we misusing the API?

Autocomplete with document content support

This seems pretty trival. But after giving some thought to it. This is pretty complex

  • a wordlist of all words in the document needs to be build (This is do-able)
  • this wordlist needs to be updated according to changes in the document. (removing and adding words)
  • this needs to happen with a responsive document
  • fuzzy searching the wordlist would be nice

For small textbuffers, regullary full-parsing is an option. For large documents this isn't an option and list updating needs to be smart.

I guess implementation version 1 will be full document parsing

Theme changing without TextThemeManager::setTheme() called

I'd like to have a function that I can use to warm up TextThemeManager's theme cache with, so I copy/pasted one to just load the theme without setting it:

/// This method just loads the given theme file.
/// The theme manager stays owner of the given theme
/// @param filename the filename of the theme to load
/// @param name the name of the theme (if the name isn't given the basename of the fileName is used (excluding the .tmTheme extension)
/// @return the loaded theme or 0 if the theme couldn't be loaded
TextTheme* TextThemeManager::loadThemeFile( const QString& fileName, const QString& nameIn )
{
    lastErrorMessage_.clear();
    // check if the file exists
    QFile file(fileName);
    if( file.exists() && file.open(QIODevice::ReadOnly) ) {
        // parse the theme
        TmThemeParser parser;
        TextTheme* theme = parser.readContent(&file);
        if( theme ) {
            // when the name is blank extract it from the filename
            QString name = nameIn;
            if( name.isEmpty() ) {
                name = QFileInfo(fileName).completeBaseName();
            }
            themeMap_.insert(name,theme);
        } else {
            lastErrorMessage_ = QObject::tr("Error parsing theme %1:%2").arg(file.fileName()).arg( parser.lastErrorMessage());
        }
        file.close();
        return theme;
    } else {
        lastErrorMessage_ = QObject::tr("Error theme not found %1.").arg(file.fileName());
        return 0;
    }
}

Or so I thought. Somehow the theme is still being changed when qApp->processEvents() is run after my function! This is even without TextThemeManager::setTheme() being touched at all.

Any ideas on what could be causing this?

forward declaration of ‘class edbee::TextEditorScrollArea’

It would seem /edbee-lib/edbee-lib/edbee/texteditorwidget.h has to include the header #include "views/texteditorscrollarea.h" if you want to make use of widget->textScrollArea()->enableShadowWidget(bool), otherwise the compiler does not like the setup:

../3rdparty/edbee-lib/edbee-lib/edbee/texteditorwidget.h:23:7: note: forward declaration of ‘class edbee::TextEditorScrollArea’
class TextEditorScrollArea;

Edbee crashes on Ctrl+Shift+Enter

When you have a blank script and press Ctrl+Shift+Enter, edbee crashes:

1   __GI_raise                                              raise.c                  58  0x7ffff3b1577f 
2   __GI_abort                                              abort.c                  89  0x7ffff3b1737a 
3   QMessageLogger::fatal(const char *, ...) const                                       0x7ffff4ca40fe 
4   qt_assert(const char *, const char *, int)                                           0x7ffff4c9f8fe 
5   edbee::GapVector<QChar>::replace                        gapvector.h              111 0x51fb2f       
6   edbee::CharTextBuffer::replaceText                      chartextbuffer.cpp       86  0x51f33b       
7   edbee::TextBuffer::replaceText                          textbuffer.cpp           104 0x51e406       
8   edbee::TextChange::replaceText                          textchange.cpp           189 0x558732       
9   edbee::TextChange::execute                              textchange.cpp           39  0x55869d       
10  edbee::TextDocument::executeAndGiveChange               textdocument.cpp         286 0x4f0f20       
11  edbee::TextDocument::replace                            textdocument.cpp         306 0x4f1d26       
12  edbee::NewlineCommand::executeSpecialNewline            newlinecommand.cpp       139 0x553c46       
13  edbee::NewlineCommand::execute                          newlinecommand.cpp       170 0x553ef2       
14  edbee::TextEditorController::executeCommand             texteditorcontroller.cpp 522 0x5227fe       
15  edbee::TextEditorController::executeCommand             texteditorcontroller.cpp 554 0x522bca       
16  edbee::TextEditorComponent::keyPressEvent               texteditorcomponent.cpp  275 0x540a52       
17  QWidget::event(QEvent *)                                                             0x7ffff6748247 
18  edbee::TextEditorComponent::event                       texteditorcomponent.cpp  230 0x5406fa       
19  QApplicationPrivate::notify_helper(QObject *, QEvent *)                              0x7ffff67094bc 
20  QApplication::notify(QObject *, QEvent *)                                            0x7ffff6712226 
... <More>                                                                                              

non-BMP characters require two keystrokes

If you paste something like 😂 into edbee and use the mouse to highlight and delete it, it works fine. However if you try to use the backspace key, you'll need two backspaces in order to delete it. Same with just pressing the 'left' key to navigate to the left of the symbol - it requires two presses:

peek 2017-06-02 06-25

Clicking in margin has seemingly abnormal behavior

When you click in a line number in the margin it selects the appropriate line and places the cursor at the beginning of the next line, which is standard functionality in every editor I've used. The part that strikes me as strange is that the line number(s) you select via margin-clicking don't get highlighted, instead only having the line that the caret lands on selected.

I think I understand why it's being done that way(because it's just highlighting whichever line the caret is on), but it seems like the more appropriate behavior would be what an editor like QtCreator does:

If any text is highlighted, highlight all lines in which text is currently selected.
Else highlight the line that the cursor is currently on(this is what edbee seems to be doing in all cases, currently).

See screenshots below for comparison between the two methods:

edbee w/ no selection:
image

QtCreator w/ no selection:
image

edbee w/ multiple lines selected(via margin clicking):
image

QtCreator w/ multiple lines selected(via margin clicking):
image

Application crash when running edbee-test under linux

When running the edbee-test under linux, I get the following output:

**************** Start edbee tests **************
class edbee::ReplaceSelectionCommandTest  ================
 - testUndo() .........

class edbee::TextRangeTest  ================
 - testMoveCaret() ....
 - testMoveCaretOrDeselect() ............
 - testMoveCaretWhileChar() ..........
 - testMoveCaretUntilChar() ......
 - testMoveCaretByCharGroup() .....
 - testMoveCaretToLineBoundary() ............

class edbee::TextRangeSetTest  ================
 - testConstructor() .
 - testAddRange() .....
 - testRangesBetweenOffsets() .............
 - testMoveCarets() ............
 - testChangeSpatial() ...
 - testGetSelectedTextExpandedToFullLines() .....
 - testSubstractRange() .....
 - testMergeOverlappingRanges() ..

class edbee::DynamicTextRangeSetTest  ================
 - testDynamicChanges() ..........
 - testDeleteMode() ......

class edbee::TextDocumentTest  ================
 - testLineData() .........................
 - testReplaceRangeSet_simple() ....
 - testReplaceRangeSet_sizeDiff() .
 - testReplaceRangeSet_simpleInsert() ..
 - testReplaceRangeSet_delete() ..

class edbee::TextBufferTest  ================
 - testlineFromOffset() ......
 - testColumnFromOffsetAndLine() .................
 - testReplaceText() ....................................
 - testFindCharPosWithinRange() ...................
 - testLine() ....
 - testReplaceIssue141() ......

class edbee::TextLineDataTest  ================
 - testLineDataManager() ..................

class edbee::GapVectorTest  ================
 - testMoveGap() ........
 - testResize() .......
 - testReplace() .................
 - testCopyRange() .............
 - testIssue141() ...
 - testIssueLineDataVector() ...

class edbee::LineOffsetVectorTest  ================
 - testMoveDeltaToIndex() .....
 - testChangeOffsetDelta() ....
 - testTextReplaced() .....
 - testFindLineFromOffset() ..........

class edbee::LineEndingTest  ================
 - testDetect() .........

class edbee::TextDocumentSerializerTest  ================
 - testLoad() ......

class edbee::TmLanguageParserTest  ================
 - testParser() 

class edbee::RegExpTest  ================
 - testRegExp() .......

class edbee::TextDocumentScopesTest  ================
 - testStartsWith() ......
 - testRindexOf() .......
 - testScopeSelectorRanking() ...........

class edbee::TextUndoStackTest  ================
Speicherzugriffsfehler (Speicherabzug geschrieben)

(The last line is the German equivalent of Memory Access Error (Memory dump written))

The stacktrace is the following:

#0  0x0000000000000018 in ?? ()
#1  0x00005603d603753d in edbee::TextDocument::replaceRangeSet
(this=0x5603d76f3260, rangeSet=..., textsIn=...)
    at ../../edbee-lib/edbee/models/textdocument.cpp:227
#2  0x00005603d603728c in edbee::TextDocument::replaceRangeSet
(this=0x5603d76f3260, rangeSet=..., textIn=...)
    at ../../edbee-lib/edbee/models/textdocument.cpp:195
#3  0x00005603d607afe6 in edbee::RemoveCommand::execute (this=0x7ffffb563dd0,
controller=0x5603d769d720)
    at ../../edbee-lib/edbee/commands/removecommand.cpp:182
#4  0x00005603d6003914 in edbee::TextUndoStackTest::testMultiCaretUndoIssue196
(this=0x5603d761bfd0)
    at ../../edbee-test/edbee/models/textundostacktest.cpp:53
#5  0x00005603d602d88d in edbee::TextUndoStackTest::qt_static_metacall
(_o=0x5603d761bfd0, _c=QMetaObject::InvokeMetaMethod, _id=0,
    _a=0x7ffffb563ff0) at moc_textundostacktest.cpp:70
#6  0x00007efeb9f949ee in QMetaMethod::invoke(QObject*, Qt::ConnectionType,
QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument,
QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument,
QGenericArgument, QGenericArgument, QGenericArgument) const () from
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00005603d605f8fe in QMetaMethod::invoke (this=0x7ffffb564260,
object=0x5603d761bfd0, val0=..., val1=..., val2=..., val3=...,
    val4=..., val5=..., val6=..., val7=..., val8=..., val9=...) at
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetaobject.h:138
#8  0x00005603d605eebd in edbee::test::TestEngine::run (this=0x5603d638e3a0
<edbee::test::engine()::engine>, test=0x5603d761bfd0)
    at ../../edbee-lib/edbee/util/test.cpp:403
#9  0x00005603d605e59d in edbee::test::TestEngine::runAll (this=0x5603d638e3a0
<edbee::test::engine()::engine>)
    at ../../edbee-lib/edbee/util/test.cpp:353
#10 0x00005603d5ffc5ec in main (argc=1, argv=0x7ffffb5645a8) at
../../edbee-test/main.cpp:67

How does one undo the effect of edbee::TextSearcher::markAll(...) ?

As a result of issue #31 we gained the ability to mark without actual selection with (void) edbee::TextSearcher::markAll (TextRangeSet *rangeset) but as a newbie to using edbee-lib it is not immediately obvious how after doing the following to "mark" a series of ranges:

edbee::TextController controller = mpSourceEditorEdbee->controller();
edbee::TextSearcher searcher = controller->textSearcher();
searcher->markAll(controller->borderedTextRanges());
controller->update();

one would then "clear" those "markings" without otherwise disturbing the document text, from looking at a15b3ca it does not seem possible to clear this by specifying a null argument to edbee::TextSearcher::markAll(...) so what needs to go in as an argument or is another method needed to remove those outline markings?

'VT' symbol/character at each line break (Linux)

Continuing my testing of edbee-lib on Linux, I managed to get a very simple editor running. I loaded the necessary files to get JavaScript syntax highlighting. Everything works pretty good, except for a character/symbol that appears at each line break, as pictured:

title

The problem appears even without loading theme and/or grammar files.

TextRange::expandToWord incorrectly selects whitespaces (Ctrl+D)

Calling the following method (effectively pressing Ctrl+D), incorrectly includes whitespaces when the caret is at the start or the end of the word.

range.exapandToWord(doc, doc->config()->whitespaces(), doc->config()->charGroups() );

Example 1

__ABCD|__x

Results in

__[ABCD__>x

Example 2

__|ABCD__x

Results in

[__ABCD>__>x

Changing showWhiteSpace option does not trigger a redraw

A project that utilises the edbee-lib downstream has found that changing only the white space mode with (void) TextEditorConfig::setShowWhitespaceMode(int) OR void TextEditorConfig::setShowWhitespaceMode(QString) does not in itself flag that a change has taken place that needs a redraw of the editor widget.

As a coder for that project (Mudlet) I have put together a PR that will correct this which I will put up shortly (once I have configured my fork of this project 😁).

HTH!

edbee tests crash under Windows

Using mingw492_32 and Qt_5_6_2 that come with the Qt for Windows installer, edbee-tests crash on Windows 10:

Starting C:\mingw32\msys\home\Vadim\src\Mudlet\3rdparty\edbee-lib\build-edbee-test-Desktop_Qt_5_6_2_MinGW_32bit-Debug\debug\edbee-test.exe...
**************** Start edbee tests **************
class edbee::RangeLineIteratorTest  ================
 - testBasicIteration() ...........
 - testSingleLineIteration() ..

class edbee::DynamicVariablesTest  ================
 - testSize() ....
 - testValue() .........

class edbee::RangeSetLineIteratorTest  ================
 - testBasicIteration() ............

class edbee::MergableChangeGroupTest  ================
 - testMoveChangesFromGroup_grow() ..................
 - testMoveChangesFromGroup_backspace() ..................
 - testMoveChangesFromGroup_delete() ............
 - testMoveChangesFromGroup_multiRangeOverlap() ............
 - testMoveChangesFromGroup_trippleDuplicateIssue() ..............
 - testMoveChangesMergeTest1() .....
 - testMoveChangesMergeTest2() ..

class edbee::TextChangeTest  ================
 - testBoundaryMethods() ........................
 - testMerge1() ....
 - testMerge2() ....
 - testMerge3() ....
 - testMerge4() ....
 - testMerge5() ....
 - testMerge6_splitMerge() ....
 - testMerge7_splitMergeInvert() ....................

class edbee::LineDataListChangeTest  ================
 - testExecute() ....
 - testMerge_growBelow() .......
 - testMerge_growAbove() .......
 - testMerge_shrinkBelow() .......
 - testMerge_shrinkAbove() .......

class edbee::RemoveCommandTest  ================
 - testSmartBackspace() ...............

class edbee::GrammarTextLexerTest  ================
 - testHamlLexer() 

class edbee::UtilTest  ================
 - testConvertTabsToSpaces() ...........
 - testTabColumnOffsets() .......

class edbee::NewlineCommandTest  ================
 WARN 11:21:05.158 "texttheme.cpp" @ 414 "Error theme not found /Monokai.tmTheme." 
 - testCalculateSmartIndent_useSpaces() ..........
 - testCalculateSmartIndent_useTabs() ...........

class edbee::DuplicateCommandTest  ================
 - testLastLineDuplication() ....
 - testDuplicateSelection() ...
 - testDuplicateMultipleCaretsOnSingleLine1() ..
The program has unexpectedly finished.
C:\mingw32\msys\home\Vadim\src\Mudlet\3rdparty\edbee-lib\build-edbee-test-Desktop_Qt_5_6_2_MinGW_32bit-Debug\debug\edbee-test.exe crashed.

Here is the stacktrace:

1  ??                                                                                                      0xfeeefeee 
2  edbee::TextDocument::replaceRangeSet                                  textdocument.cpp             235  0x4540ce   
3  edbee::DuplicateCommand::execute                                      duplicatecommand.cpp         61   0x4a64e9   
4  edbee::TextEditorController::executeCommand                           texteditorcontroller.cpp     508  0x456253   
5  edbee::TextEditorController::executeCommand                           texteditorcontroller.cpp     540  0x456498   
6  edbee::DuplicateCommandTest::testDuplicateMultipleCaretsOnSingleLine3 duplicatecommandtest.cpp     119  0x42a3f0   
7  edbee::DuplicateCommandTest::qt_static_metacall                       moc_duplicatecommandtest.cpp 98   0x446f4f   
8  QMetaMethod::invoke                                                   qmetaobject.cpp              2211 0x15fdac66 
9  QMetaMethod::invoke                                                   qmetaobject.h                132  0x4d991a   
10 edbee::test::TestEngine::run                                          test.cpp                     403  0x44f1b0   
11 edbee::test::TestEngine::runAll                                       test.cpp                     353  0x44e6eb   
12 qMain                                                                 main.cpp                     67   0x41fbbe   
13 WinMain *16                                                           qtmain_win.cpp               113  0x449790   
14 main                                                                                                    0x4e392d   

Here is the data:

	Locals		
		controller	@0x2f3f7f0	edbee::TextEditorController
			[QObject]	@0x1dc17f48	QObject
			autoScrollToCaret_	edbee::TextEditorController::AutoScrollAlways (0)	edbee::TextEditorController::AutoScrollToCaret
			commandMapRef_	@0x1dc17f6c	edbee::TextEditorCommandMap
			commandMap_	0x0	edbee::TextEditorCommandMap*
			keyMapRef_	@0x1dc17f64	edbee::TextEditorKeyMap
			keyMap_	0x0	edbee::TextEditorKeyMap*
			staticMetaObject	@0x4f20c4	QMetaObject
			textCaretCache_	@0x1dc17f74	edbee::TextCaretCache
			textDocumentRef_	@0x1dc17f58	edbee::CharTextDocument
			textDocument_	@0x1dc17f54	edbee::CharTextDocument
			textRenderer_	@0x1dc17f70	edbee::TextRenderer
			textSearcher_	0x0	edbee::TextSearcher*
			textSelection_	@0x1dc17f5c	edbee::TextSelection
			widgetRef_	@0x1dc17f50	edbee::TextEditorWidget
		delta	14	int
		doc	@0x1dc18a10	edbee::CharTextDocument
		newRanges	@0x2f3f79c	edbee::TextRangeSet
			[edbee::TextRangeSetBase]	@0x2f3f79c	edbee::TextRangeSetBase
			selectionRanges_	<2 items>	QVector<edbee::TextRange>
				[0]	@0x1dc14d90	edbee::TextRange
					anchor_	7	int
					caret_	7	int
				[1]	@0x1dc14d98	edbee::TextRange
					anchor_	7	int
					caret_	7	int
		newSelection	@0x2f3f7d4	edbee::TextRangeSet
			[edbee::TextRangeSetBase]	@0x1dc14fa0	edbee::TextRangeSetBase
			selectionRanges_	<2 items>	QVector<edbee::TextRange>
				[0]	@0x1dc14dc8	edbee::TextRange
					anchor_	15	int
					caret_	15	int
				[1]	@0x1dc14dd0	edbee::TextRange
					anchor_	17	int
					caret_	17	int
		newTexts	<2 items>	QStringList
			[0]	"abcdef\n"	QString
			[1]	"abcdef\n"	QString
		this	@0x2f3f78c	edbee::DuplicateCommand
			[edbee::TextEditorCommand]	@0x1dbf0770	edbee::TextEditorCommand
				[vptr]	_vptr.TextEditorCommand	 
	Inspector		
	Expressions		
	Return Value		
	Tooltip		

How to hook into the right-click menu?

How can I add a custom action to the right-click menu? Looking at TextEditorComponent::contextMenuEvent() I don't see a way.

I'd like to add an action to run an indenter on the selected code, for example.

TextDocumentSerializer should not close ioDevice

TextDocumentSerializer should not close ioDevice because it is not the owner of ioDevice and some QIODevice does not allow to close it.
For example QSaveFile (ideal for text editor), could not close device.

https://github.com/edbee/edbee-lib/blob/master/edbee-lib/edbee/io/textdocumentserializer.cpp#L93
https://github.com/edbee/edbee-lib/blob/master/edbee-lib/edbee/io/textdocumentserializer.cpp#L168

For me, this two lines should be removed. Thanks !

Autocomplete support

Entering text should quickly display a menu like the one below.
Showing all symbols/words/keywords..
Can be confirmed with enter or closed with esc

image

The LICENCE file only refers to Oniguruma and not to Onigmo libraries

It needs to be updated to include the contents of /vendor/onig/COPYING file to enable users of the edbee-lib library to be aware of and meet their requirements specified in that file for the use of the Onigmo files particularly if they then distribute binaries...!

{I spotted this as I'm just going through and checking for non-GPL licensed libraries that we include in Mudlet source and binary code - 🙂}

Font size forced to 10 in margin causes display problems

The editor is forcing the line numbers to be drawn at 10 point in whatever font the editor is using, causing abnormalities when you use other font sizes.

Here's what the issue looks like using Consolas 7pt:
image

And here's a different consequence of the forced font size with Consolas 20pt:

image

Use of raw string literal causes issues when QT_NO_CAST_FROM_ASCII #defined

In the declaration for (virtual void) TextupdateStatusText(const QString&) in /edbee-lib/edbee/texteditorcontroller.h the use of a raw "" causes a compilation failure should an application include the edbee-lib widget and also #define QT_NO_CAST_FROM_ASCII.

This #define is used in order to locate QStrings that are initialised with raw string literals instead of being instantiated and marked as either:

  • to be part of the GUI and to be made translatable with creation via calls to QObject::tr(...) or related methods
  • to marked as internal and NOT translatable with creation via QStringLiteral(...) or QLatin1String(...)

To correct this, simply modify the default value here:

virtual void updateStatusText( const QString& extraText="" );

to:

virtual void updateStatusText( const QString& extraText=QString() ); 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.