Giter Club home page Giter Club logo

imguicolortextedit's People

Contributors

alexanderbrevig avatar balazsjako avatar berdal84 avatar green-sky avatar marcel303 avatar onqtam avatar sadovsf avatar samhocevar 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  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  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

imguicolortextedit's Issues

TextBox

How to change the size of the textbox

SelectAll fails to do anything when there's only one line

SetSelection(Coordinates(0, 0), Coordinates((int)mLines.size(), 0));
Would resolve to Coordinates(0,0), Coordinates(1,0), which is then sanitised by SetSelection to Coordinates(0,0),Coordinates(0,0), resulting in no selection as the end coord is beyond the end of the document.

I've fixed this locally by changing it to select the last character of the last line instead of the line beyond the end of the document:

void TextEditor::SelectAll()
{
	if(!mLines.empty())
		SetSelection(Coordinates(0, 0), Coordinates((int)mLines.size()-1, mLines.back().size()));
}

Are you open to pull requests ? (custom width/height fonts)

I'm working on a tool, if you're interested: https://github.com/berdal84/Nodable/
I would like to be able to use your imGuiColorTextEdit with custom width/height fonts.
I'll be happy to contribute by adding custom font handling, are you open to it ? If yes, any suggestions to do it before I start ?

A capture of your ImGuiColorTextEdit integrated into my app :
https://github.com/berdal84/Nodable/blob/texteditor/screenshots/2018_06_03_Testing_ImGuiColorTextEdit.png

Colorizer is slow

Colorizer uses std::regex, but it is too slow for that amount of work. Not to mention it is not optimized to scan multiple expressions at once. It is necessary to replace it with a proper lexical scanner (like RE/Flex).

Invalid cursor position after mouse click on line with tabulations

Problem

When I click on a line contening tabulations, the cursor is placed at a wrong position.

For example, calling only these two functions with the default font of ImGui:

editor.SetText("        abcdefghijklmnopqrstuvwxyz\n\t\tabcdefghijklmnopqrstuvwxyz\n");
editor.Render("editor", ImGui::GetContentRegionAvail(), false);

Screenshot_20190613_172825

If I click after the text on the first line the cursor is put at the right position (the end of the line), but if I click after the end of the second line the cursor is placed at a wrong position (as in the picture).

Informations

Standard control key combinations - requests

Its cool that we can go through words with Ctrl+ Left/Right and etc. but perhaps more standard controls like Ctrl+A for selecting everything (and others I can't think of right now) might be a big plus :)

Backspace and Delete affect Breakpoints and ErrorMarkers differently

Removing a line using delete removes the marker on that line, as expected.
Removing a line using backspace however, doesn't. Using backspace to delete the line below the marker does remove it though.

A bit of an inconsistency in their behavior.

I will try to make a fix myself. But that requires rewriting either Delete() or Backspace(), while maintaining the other existing behavior.

Cursor position is more off with each character on line

Longer the line more cursor gets off to right from place it is writing. I tried multiple fonts along with monospaced one but nothing helped. Maybe some change in recent ImGui? I'am using release of 1.68 made recently. Here is the issue visible:
image

Cursor is there actually at the end of the line (when i press delete last character on line dissapears)

Block comments are highlighted incorrectly in Lua

Most languages have completely different tokens for single-line comments and block comments (eg // and /* */ in C), but in Lua they start the same: -- and --[[.
The comment highlighting logic needs fixing so that it prioritises block comments first.

I've fixed this locally by swapping the logic over:

if(currentIndex + startStr.size() <= line.size() &&
	equals(startStr.begin(), startStr.end(), from, from + startStr.size(), pred))
{
	commentStartLine = currentLine;
	commentStartIndex = currentIndex;
}
else if (singleStartStr.size() > 0 &&
	currentIndex + singleStartStr.size() <= line.size() &&
	equals(singleStartStr.begin(), singleStartStr.end(), from, from + singleStartStr.size(), pred))
{
	withinSingleLineComment = true;
}

Crash when SetString("")

If I set an empty string :
editor.SetString("");
And then I click into the Text Editor area I got an assert (aLine is wrong).

Triple left-click should select whole line.

Also it would be grand if the double-click glob chars could be changed, I'm thinking about ":" specifically. In passwd and shadow files It's great to stop at : but for "scp host:file ." it's unfortunate.

Improved comment parsing broke some parsers

There are two issues introduced in 8fbb932:

  • langDef.mSingleLineComment = "--"; was removed from the Lua language definition.
  • ColorizeInternal() will set withinSingleLineComment to true if mSingleLineComment is the empty string, so a language that does not have comments (e.g. JSON) will be fully colorised as comments

TextEditor::Glyph::mColorIndex is too small.

g++ -I../cimgui/imgui -I../../include   -c -o TextEditor.o TextEditor.cpp
In file included from TextEditor.cpp:7:0:
TextEditor.h:125:30: warning: ‘TextEditor::Glyph::mColorIndex’ is too small to hold all values of ‘enum class TextEditor::PaletteIndex’
   PaletteIndex mColorIndex : 7;

This is on i686, 32bit linux.

Colorizing lag

We've noticed that there's a lag colorizing new text - as you're typing it renders in the default color for a frame before the syntax highlighting kicks in.

It appears this is happening because when ColorizeInternal goes down the multi-line comment path, it returns rather than continuing to do the main colorization pass. This results in a two-stage process where commenting is checked on frame 1, and then syntax highlighting applies on frame 2.

Is there a reason for it being this way? I can see any bad effects after removing the return locally. According to blame, it's always been there.

WantCaptureKeyboard and WantTextInput problems from ImGuiIO

When a code editor widget is focused and has a cursor inside of it - querying ImGui::GetIO().WantCaptureKeyboard or ImGui::GetIO().WantTextInput (or maybe both) should return true instead of false. Also not sure about WantCaptureMouse and the rest such flags.

Great project btw! Thanks for making it public!

warning produced by gcc

The following warning is produced from the header with gcc 7:

TextEditor.h:125:30: warning: 'TextEditor::Glyph::mColorIndex' is too small to hold all values of 'enum class TextEditor::PaletteIndex'
   PaletteIndex mColorIndex : 7;

on the default warning level - and it cannot be easily silenced (without disabling all warnings with -w)

Suggestion: move .png/large data to wiki repo

Minor trick/suggestion: because png adds up in the git repo size.
The wiki that github offers is a separate git repo (ImGuiColorTextEdit.wiki.git instead of ImGuiColorTextEdit.git)

What I do for imgui is I upload any images to the wiki repo and link to them from the readme instead, so the main repository doesn't grow with extra data.

Error from clang

Inside GetDarkPalette(), GetLightPalette() and GetRetroBluePalette()

error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]

I've fixed this locally by double-bracing the initialisation lists so they look like this:

static Palette p = {{ 
		0xffffffff,	// None
		0xffd69c56,	// Keyword	
		0xff00ff00,	// Number
		0xff7070e0,	// String
		0xff70a0e0, // Char literal
		0xffffffff, // Punctuation
		0xff409090,	// Preprocessor
		0xffaaaaaa, // Identifier
		0xff9bc64d, // Known identifier
		0xffc040a0, // Preproc identifier
		0xff206020, // Comment (single line)
		0xff406020, // Comment (multi line)
		0xff101010, // Background
		0xffe0e0e0, // Cursor
		0x80a06020, // Selection
		0x800020ff, // ErrorMarker
		0x40f08000, // Breakpoint
		0xff707000, // Line number
		0x40000000, // Current line fill
		0x40808080, // Current line fill (inactive)
		0x40a0a0a0, // Current line edge
	}};

feature request - word wrap (or line wrap) support

It would be nice if the rendered text could wrap around (optionally with some flag) so we don't have to scroll horizontally when the lines are too long

I understand that this project doesn't aim to be a complete editor - I'm just suggesting... :D

Multi-line comment detected within single line comment (c++).

Hi,

The following code has incorrect syntax highlighting. One can verify this by copy-pasting it into the editor.

	if (hasValue == false && nodeId != kGraphNodeIdInvalid)
	{
		//logDebug("reset realTimeSocketCapture");
		//*this = GraphEdit_Visualizer();
	}
	
	//
	
	const bool hasChannels = channelData.hasChannels();
	
	if (hasChannels)
	{

I investigated why, and it's caused by the multi-line comment highlighter running before single line comments are detected. It causes the '/*' in '//*this' above to be interpreted as the start of a multi-line comment. While it should be ignored as it's part of a single line comment. A possible solution would be to detect single line comments together with multi-line ones.

Perhaps eventually to make (multi-line) comments work well across different languages we'll need a separate comment highlighter for each language.

make it compile with gcc

with GCC the <cmath> header needs to be included for floor() in the .cpp - this PR fixes that.

Currently I have a workaround in a demo project (as can be seen here) which I would like to remove so that the code is simpler - people will be looking at it when I make an official release of that example project.

Small issue with fonts

image

Hi, I hope you can read that :). I encountered a little problem with fonts, it looks like you use the first one in the array of fonts in ImGui, and if you are using different fonts that doesn't seem to work...

void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder)
{
	mWithinRender = true;

	ImGuiIO& io = ImGui::GetIO();
	auto xadv = (io.Fonts->Fonts[0]->IndexAdvanceX['X']);
	mCharAdvance = ImVec2(xadv, io.Fonts->Fonts[0]->FontSize + mLineSpacing);

My solution was passing the used font as an argument in the "Render" function, although I think that it'd be better to acces the currently used font from the ImGui io.

void TextEditor::Render(const char* aTitle,ImFont* font, const ImVec2& aSize, bool aBorder)
{
	mWithinRender = true;

	ImGuiIO& io = ImGui::GetIO();
	auto xadv = (font->IndexAdvanceX['X']);
	mCharAdvance = ImVec2(xadv, font->FontSize + mLineSpacing);

Having said that, your API i great, the fact that you can make custom colors for different languages is really good. I'll make one for "wren", and pass it to you in case you want to merge it with the source code.

enable build with c++11

Hi! currently the source code requires c++14.
Only 2 lines of code have to be changed to enable c++11 builds - where std::equals() is used.

Extremely long startup times

Including this lib in my project causes the time from starting the executable to the time the window is displayed to be increased by several seconds.

I would appreciate any input about this issue, such as why it might be so long, and what if anything I might do about it.

I really like this lib otherwise, but more than tripling my startup time is hard to accept.

FWIW I'm using this with ImGui 1.69, sdl2 and gl3w. I'm using the default impl_sdl and impl_opengl3.

AltGr-handling

in:
void TextEditor::HandleKeyboardInputs()

this row:
else if (!IsReadOnly() && !ctrl && !alt)

makes the texteditor unable to enter any characters requiring AltGr key to be pressed (coded as Ctrl+Alt in European Windows). (for instance { } [ ] etc)

Quick fix for those affected is to remove the !ctrl and !alt check.

This issue doesn't exist within ImGui's inputtext itself.

Do you reckon there's a better fix for this issue?

Read-only mode

Would be nice if there was an easy way to make the editor read only. Selections and such would still be possible, but text input, deletions etc would be locked.

It may be possible now. Maybe I just missed it. If not, it would be nice.

UTF8 support?

The readme says no UTF8 support... how far would that be on the horizon? Would it involve a lot of changes?

Auto-indent

Probably needs a languagehelper-like class.

Text changed return value from Render?

It would be useful to be able to receive information about when the text has been changed (eg to trigger a Lua script load to check for errors in realtime).

Naively, this could be done by the user comparing GetText() with the previous value, but it's a bit of a sledgehammer approach.

Better would be implemented with a "text changed" member bool that's set inside any text manipulation function that adjusts the undo index. The flag would be returned and cleared at the end of Render().

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.