Code Monkey home page Code Monkey logo

imguicolortextedit's Introduction

About this fork

You can use https://github.com/santaclose/ste as a demo.

Feel free to join my discord server if you want to discuss anything about this fork.

Features I've been working on:

  • multicursor (ctrl + click to add a new one)
  • ctrl + d for selecting next match
  • ctrl + [ and ctrl + ] for indentation
  • more language definitions for syntax highlighting
  • switched to boost regex which seems more stable
  • ctrl + backspace and ctrl + delete for word mode delete
  • ctrl + / for comment toggling
  • it works without setting a language definition
  • middle mouse button for panning

ImGuiColorTextEdit

Syntax highlighting text editor for ImGui

Screenshot

Demo project: https://github.com/BalazsJako/ColorTextEditorDemo

This started as my attempt to write a relatively simple widget which provides text editing functionality with syntax highlighting. Now there are other contributors who provide valuable additions.

While it relies on Omar Cornut's https://github.com/ocornut/imgui, it does not follow the "pure" one widget - one function approach. Since the editor has to maintain a relatively complex and large internal state, it did not seem to be practical to try and enforce fully immediate mode. It stores its internal state in an object instance which is reused across frames.

The code is (still) work in progress, please report if you find any issues.

Main features

  • approximates typical code editor look and feel (essential mouse/keyboard commands work - I mean, the commands I normally use :))
  • undo/redo
  • UTF-8 support
  • works with both fixed and variable-width fonts
  • extensible syntax highlighting for multiple languages
  • identifier declarations: a small piece of description can be associated with an identifier. The editor displays it in a tooltip when the mouse cursor is hovered over the identifier
  • error markers: the user can specify a list of error messages together the line of occurence, the editor will highligh the lines with red backround and display error message in a tooltip when the mouse cursor is hovered over the line
  • large files: there is no explicit limit set on file size or number of lines (below 2GB, performance is not affected when large files are loaded (except syntax coloring, see below)
  • color palette support: you can switch between different color palettes, or even define your own
  • whitespace indicators (TAB, space)

Known issues

  • syntax highligthing of most languages - except C/C++ and Lua - is based on std::regex, which is diasppointingly slow. Because of that, the highlighting process is amortized between multiple frames. C/C++ and Lua have a hand-written tokenizer which is much faster.

Please post your screenshots if you find this little piece of software useful. :)

Contribute

If you want to contribute, please refer to CONTRIBUTE file.

imguicolortextedit's People

Contributors

aeris170 avatar alexanderbrevig avatar balazsjako avatar berdal84 avatar green-sky avatar hacke-rc avatar marcel303 avatar onqtam avatar pthom avatar sadovsf avatar samhocevar avatar santaclose avatar sphaero 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

Watchers

 avatar  avatar  avatar

imguicolortextedit's Issues

Issue with Text Rendering using External Fonts

I'm encountering an issue with text rendering when using an external font. The original branch displays the text correctly and functions as expected. However, when I switch to the fork branch, the text alignment appears to be different, causing inconsistencies in the rendering.

Steps to Reproduce:

Switch to the original branch and observe the text rendering with an external font.
Switch to the fork branch and compare the text alignment with the original branch.
Notice the differences in text alignment between the original and fork branches.
Additional Details:

The external font being used: Robotto.ttf
Screenshots showcasing the issue on both branches:

santaclose:
Capture2

BalazsJako:
Capture

This issue affects the consistency and appearance of the text rendering, particularly when using external fonts.

Side effects of 'stop updating palette every frame and add default palette interface' commit

Commit eab54a3 stops updating the palette every frame and added a new default palette interface.

While speeding up the rendering loop is always a good idea, this change causes two side effects that are now hampering me:

  • The ability to have a custom color palette, which I was using, is now lost.
  • Changes to ImGui::GetStyle().Alpha are no longer automatically handled. In one of my applications, I give the user control over the transparency of the GUI and I now have to set a new palette on the editor every time they change transparency.

My implementation at goossens@d738eaf achieves the same thing you were after without the side effects.

It also maintains backwards compatibility for those who quickly want to change over from the old library to yours. 😄

Short Tab Rendering

At some point, the ability to render tabs as short arrows was removed from this fork. As a user of Visual Studio Code, I like this feature as it make the editor look cleaner.

In commit goossens@efe2c55, I’ve added it back in to my fork with configurable setting (default is off). Recommend you consider putting it back into this fork.

Let me know if you want a pull request.

Show Matching Brackets Bug

Commit 0226e18 (show matching brackets) is a wonderful feature that I already had in my fork and it’s great to have it here. Unfortunately, there is a bug since it doesn’t handle empty lines correctly when it’s finding matching brackets.

Commit goossens@6ff7321 in my fork fixes the problem and as a bonus, it makes the “show matching brackets” optional.

Let me know if you want a pull request.

Autocomplete Paired Glyphs

In my old fork of ImGuiColorTextEdit, I had a feature to autocomplete paired glyphs. So when typing [, {, (, “ or ‘, the matching glyph was also added. Undo removed both characters. The feature is configurable and the default is off.

I have ported this feature to this fork and you can see my changed at goossens@66d8c59. Let me know if you want a put request.

Let me know if you want a pull request.

Easy way to make boost::regex Optional

In issue #6, there was a discussion on making the use of the boost::regex library optional. I have two project where I’m using ImGuiColorTextEdit. In the first one, I’m using regex-based syntax highlighting and using boost is not an issue. I’m doing another project with someone who is very allergic to anything boost and we’re not using regex based syntax coloring.

To support both scenarios, we changed one line in TextEditor.h to six lines and now everybody can be happy.

Change:

#include <boost/regex.hpp>

to:

#ifdef IMGUI_EDITOR_NO_BOOST
    #include <regex>
    namespace boost = std;
#else
    #include <boost/regex.hpp>
#endif

Those that want to use boost don’t have to do anything. Those that are allergic to boost or don’t care for another dependency, can define IMGUI_EDITOR_NO_BOOST in their Makefile or whatever IDE that are using.

You can see my implementation at goossens@9566688. Let me know if you want a pull request.

Future of this ImGuiColorTextEdit Fork

This is not really an issue but more of a philosophical discussion to get feedback on the way forward.

Like many other people, I’ve been frustrated with the state of ImGuiColorTextEdit. The original author doesn’t have the time to work on it and the many forks are all over the place. I contributed to this mess by creating my own fork and i did a sort of best of class integration of the various ideas. I was never satisfied with it since a number of fundamental problems/bugs were still around.

This forks seems to be the most promising so I’m going to start using it. Unfortunately, I’m already relying on features of the original that are no longer available as well as ideas I’m using from other forks. I have therefore started a new fork (based on this one) at https://github.com/goossens/ImGuiColorTextEdit so I can keep track of changes and patches.

To have a proper discussion on the things I need, I’ll raise an issue for each topic so we can see if you want to integrate it in your repository. I’ll will also link to the commits in my fork for clarification and if desired, I’ll create a pull request.

Let me know what you think.

Syntax Highlighting stops working when case sensitivity is toggled

When creating a language definition, after setting up all the keywords and identifiers, if I set the mCaseSensitive member of the LanguageDefinition struct to true (assuming my keywords and identifiers are in lowercase) the syntax highlighting works perfectly, as shown below:
image

But, when I switch it to false, I expect it to highlight both the uppercase and lowercase identifiers in the same way, but it does not do that and syntax highlighting just stops working, as shown below:
image

I suspect it has something to do with this line:
image

But I'm not entirely sure.

Input Text

Hi, aim trying to achieve a simple ImGui multiline input text with support for word wrapping. No scrolling (auto-grow vertically), no syntax highlighting, no line numbers, just editable text. Is this possible with this control? Is it suitable for that?

If so I need multiple of those on my screen. Can I expect performance close to the ImGui's built-in Text Input with all visual features turned off?

Thanks for the great work.

Compilation errors with Clang

I can’t compile the current version due to errors in the rewrite of FindWordStart and FindWordEnd. When those methods were changed in commit 6ee401b to use the new Move method, the aFront calling parameters is changed although it’s declared as a const reference. I’m surprised the Windows compiler allowed it (even with the type cast).

The offending lines in FindWordStart and FindWordEnd are the ones with the Move calls like:

while (Move((int)aFrom.mLine, charIndex, true, true))

My simple fix was to use the same pattern that was already used in the (now deleted) FindNextWord method. You can see my change at goossens@583fc70.

Error and Breakpoint Highlighting

At some point, error and breakpoint highlighting were removed from this fork. In my use of ImGuiColorTextEdit, I used these features so I’m now stuck.

Given that the color palettes still have colors for these features, I’m not sure if you are planning to bring them back later or if you forgot to remove the colors.

So before I go reimplement these features in my own fork, what is your plan in this area?

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.