Skip to content
This repository was archived by the owner on Dec 2, 2019. It is now read-only.

Conversation

@zecruel
Copy link

@zecruel zecruel commented Mar 7, 2019

Bug fixes:

  • Weird behavior in text edit when using multibyte utf8 characters (mainly in paste operations). Apparently was a mistake in calculating the length of string.
  • Text rendering out of bondary rectangle in multiline text edit. In this case, clip area must be recalculated.

New widget feature:

  • Auto wrap text in multiline edit. I do not know if it's the most elegant and stable solution, but it's working fine.

Bug fixes and add new widget feature: text edit multiline auto wrap
@irtusb
Copy link

irtusb commented Mar 7, 2019

i wonder who uses vertical tab '\v' these days

@dumblob
Copy link
Contributor

dumblob commented Mar 12, 2019

I've looked at the source and the use of \v seems correct to me.

@zecruel could you please make the changes in source files (see the src/ directory), bump version (we're following Semver), and run amalgamation?

zecruel added 2 commits March 14, 2019 08:47
Add feature: Multiline edit widget with automatic text wrap. Fix some bugs too.
{
if (unicode == '\n') {
if (unicode == '\n' || unicode == '\v') {
/* new line separator so draw previous line */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For edit auto wrap feature. Consider a vertical tab (\v) as a line break too.

}
if (unicode == '\n') {
if (unicode == '\n' || unicode == '\v') {
text_size.x = NK_MAX(text_size.x, line_width);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For edit auto wrap feature. Consider a vertical tab (\v) as a line break too.

while ((text_len < byte_len) && glyph_len) {
if (unicode == '\n') {
if (unicode == '\n' || unicode == '\v') {
text_size.x = NK_MAX(text_size.x, line_width);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For edit auto wrap feature. Consider a vertical tab (\v) as a line break too.

nk_textedit_makeundo_insert(state, state->cursor, glyphs);
state->cursor += len;
state->cursor += glyphs;
state->has_preferred_x = 0;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix: weird behavior on multibyte characters operations.

{
return nk_str_insert_text_utf8(str, pos, text, nk_strlen(text));
return nk_str_insert_text_char(str, pos, text, nk_strlen(text));
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix: weird behavior on multibyte characters operations.

root = root->parent;
}
win->popup.buf.active = is_active;
return is_active;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix: combo boxes crashes program (points to invalid memory) in draw rotine.

}
NK_API nk_flags
nk_edit_string_zero_terminated(struct nk_context *ctx, nk_flags flags,
char *buffer, int max, nk_plugin_filter filter)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add feature: Multiline edit box with automatic text wrap.

if (cursor_pos.y < edit->scrollbar.y)
edit->scrollbar.y = NK_MAX(0.0f, cursor_pos.y - row_height);
if (cursor_pos.y >= edit->scrollbar.y + area.h)
if (cursor_pos.y >= edit->scrollbar.y + area.h - row_height)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix: text rendering out of clip box.

old_clip = out->clip;
nk_unify(&clip, &old_clip, area.x, area.y, area.x + area.w, area.y + area.h);
}
if (edit->active)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix: text rendering out of clip box.

@zecruel
Copy link
Author

zecruel commented Mar 14, 2019

I've looked at the source and the use of \v seems correct to me.

@zecruel could you please make the changes in source files (see the src/ directory), bump version (we're following Semver), and run amalgamation?

Done. Please verify if I made correctly.
I add some comments in pull request for better explanation.

else tolerance = byte_len - text_len; /* tolerance until the string end */
if (tolerance > 3){ /* need to break */
if (last_spc){ /* if has a good point for break, use it */
nk_str_insert_text_char(&edit->string, last_spc + 1, "\v", 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vurtun does something like this happen also on other places in the library?

IMHO we shall not allow this as we can't guarantee, that we'll put the string to it's original state once edited internally by Nuklear (because it's not distinguishable from a user made edition). It seems also not intuitive for the programmer to edit the string internally when the function itself is "just for visualisation" (this edition of "inserting \v" is not done by user).

I can though understand, that such internal editions do make the code simpler. For that purpose we could consider something like a string view providing this "metainformation" about internally inserted/deleted characters, but not editing the underlying string unless it's a user made edition.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants