[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54456] trunk/blender/source/blender/ editors/space_console: patch [#34192] UTF-8 input in Python interactive console
Campbell Barton
ideasman42 at gmail.com
Mon Feb 11 10:40:33 CET 2013
Revision: 54456
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54456
Author: campbellbarton
Date: 2013-02-11 09:40:33 +0000 (Mon, 11 Feb 2013)
Log Message:
-----------
patch [#34192] UTF-8 input in Python interactive console
from Shinsuke Irie (irie)
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_console/console_draw.c
trunk/blender/source/blender/editors/space_console/console_ops.c
Modified: trunk/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_draw.c 2013-02-11 09:30:04 UTC (rev 54455)
+++ trunk/blender/source/blender/editors/space_console/console_draw.c 2013-02-11 09:40:33 UTC (rev 54456)
@@ -158,9 +158,9 @@
if (tvc->iter_index == 0) {
const SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
const ConsoleLine *cl = (ConsoleLine *)sc->history.last;
- const int prompt_len = strlen(sc->prompt);
- const int cursor_loc = cl->cursor + prompt_len;
- const int line_len = cl->len + prompt_len;
+ const int prompt_len = BLI_strlen_utf8(sc->prompt);
+ const int cursor_loc = BLI_strnlen_utf8(cl->line, cl->cursor) + prompt_len;
+ const int line_len = BLI_strlen_utf8(cl->line) + prompt_len;
int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
int pen[2];
xy[1] += tvc->lheight / 6;
Modified: trunk/blender/source/blender/editors/space_console/console_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_ops.c 2013-02-11 09:30:04 UTC (rev 54455)
+++ trunk/blender/source/blender/editors/space_console/console_ops.c 2013-02-11 09:40:33 UTC (rev 54456)
@@ -36,6 +36,7 @@
#include "BLI_listbase.h"
#include "BLI_string_cursor_utf8.h"
+#include "BLI_string_utf8.h"
#include "BLI_string.h"
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
@@ -393,15 +394,26 @@
{
// if (!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */
if (!RNA_string_length(op->ptr, "text")) {
- /* if alt/ctrl/super are pressed pass through */
- if (event->ctrl || event->oskey) {
+ /* if alt/ctrl/super are pressed pass through except for utf8 character event
+ * (when input method are used for utf8 inputs, the user may assign key event
+ * including alt/ctrl/super like ctrl+m to commit utf8 string. in such case,
+ * the modifiers in the utf8 character event make no sense.) */
+ if ((event->ctrl || event->oskey) && !event->utf8_buf[0]) {
return OPERATOR_PASS_THROUGH;
}
else {
- char str[2];
- str[0] = event->ascii;
- str[1] = '\0';
-
+ char str[BLI_UTF8_MAX + 1];
+ size_t len;
+
+ if (event->utf8_buf[0]) {
+ len = BLI_str_utf8_size_safe(event->utf8_buf);
+ memcpy(str, event->utf8_buf, len);
+ }
+ else {
+ /* in theory, ghost can set value to extended ascii here */
+ len = BLI_str_utf8_from_unicode(event->ascii, str);
+ }
+ str[len] = '\0';
RNA_string_set(op->ptr, "text", str);
}
}
More information about the Bf-blender-cvs
mailing list