Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-24 08:18:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-24 08:18:28 +0400
commit0503a4f7a6fa2aba573ff4f8d4c6d7f387894952 (patch)
tree26fa3836cd19536e6445ef4aad8fcecece1614f3 /source/blender/windowmanager
parent618d4d1a6e4a3df8399549fa80846cdeacb7299c (diff)
parent2bd9519e39f7c383005fd531f4c7dd92cce246ad (diff)
svn merge ^/trunk/blender -r41100:41150
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_types.h4
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c3
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c83
3 files changed, 86 insertions, 4 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index fec59e97194..f28fb08ac6e 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -341,8 +341,8 @@ typedef struct wmEvent {
short val; /* press, release, scrollvalue */
int x, y; /* mouse pointer position, screen coord */
int mval[2]; /* region mouse position, name convention pre 2.5 :) */
- short unicode; /* future, ghost? */
- char ascii; /* from ghost */
+ char utf8_buf[6]; /* from, ghost if utf8 is enabled for the platform */
+ char ascii; /* from ghost, fallback if utf8 isnt set */
char pad;
/* previous state */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 33e98007fed..6fd84b4c315 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1146,7 +1146,7 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi)
/* the matching rules */
if(kmitype==KM_TEXTINPUT)
- if(ISTEXTINPUT(winevent->type) && winevent->ascii) return 1;
+ if(ISTEXTINPUT(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1;
if(kmitype!=KM_ANY)
if(winevent->type!=kmitype) return 0;
@@ -2578,6 +2578,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
GHOST_TEventKeyData *kd= customdata;
event.type= convert_key(kd->key);
event.ascii= kd->ascii;
+ strcpy(event.utf8_buf, kd->utf8_buf);
event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE;
/* exclude arrow keys, esc, etc from text input */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index b0183d05ac2..1face062e7e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -56,7 +56,6 @@
#include "BLI_blenlib.h"
#include "BLI_dynstr.h" /*for WM_operator_pystring */
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
@@ -105,6 +104,11 @@
static GHash *global_ops_hash= NULL;
+#ifdef WITH_PYTHON_UI_INFO
+# include "DNA_text_types.h"
+# include "BKE_text.h"
+#endif
+
/* ************ operator API, exported ********** */
@@ -3505,6 +3509,79 @@ static void operatortype_ghash_free_cb(wmOperatorType *ot)
MEM_freeN(ot);
}
+#ifdef WITH_PYTHON_UI_INFO
+
+static ScrArea *biggest_text_view(bContext *C)
+{
+ bScreen *sc= CTX_wm_screen(C);
+ ScrArea *sa, *big= NULL;
+ int size, maxsize= 0;
+
+ for(sa= sc->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_TEXT) {
+ size= sa->winx * sa->winy;
+ if(size > maxsize) {
+ maxsize= size;
+ big= sa;
+ }
+ }
+ }
+ return big;
+}
+
+static int wm_text_edit_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain= CTX_data_main(C);
+ Text *text;
+
+ char filepath[240];
+ int line= RNA_int_get(op->ptr, "line");
+ RNA_string_get(op->ptr, "filepath", filepath);
+
+ for (text=bmain->text.first; text; text=text->id.next) {
+ if (text->name && BLI_path_cmp(text->name, filepath) == 0) {
+ break;
+ }
+ }
+
+ if (text == NULL) {
+ text= add_text(filepath, bmain->name);
+ }
+
+ if (text == NULL) {
+ BKE_reportf(op->reports, RPT_WARNING, "file: '%s' can't be opened", filepath);
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ /* naughty!, find text area to set, not good behavior
+ * but since this is a dev tool lets allow it - campbell */
+ ScrArea *sa= biggest_text_view(C);
+ if(sa) {
+ SpaceText *st= sa->spacedata.first;
+ st->text= text;
+ }
+
+ txt_move_toline(text, line - 1, FALSE);
+ WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+static void WM_OT_text_edit(wmOperatorType *ot)
+{
+ ot->name= "Edit Text File";
+ ot->idname= "WM_OT_text_edit";
+
+ ot->exec= wm_text_edit_exec;
+
+ RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "Path", "");
+ RNA_def_int(ot->srna, "line", 0, INT_MIN, INT_MAX, "Line", "", 0, INT_MAX);
+}
+
+#endif /* WITH_PYTHON_UI_INFO */
+
+
/* ******************************************************* */
/* called on initialize WM_exit() */
void wm_operatortype_free(void)
@@ -3548,6 +3625,10 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_collada_import);
#endif
+#ifdef WITH_PYTHON_UI_INFO
+ WM_operatortype_append(WM_OT_text_edit);
+#endif
+
}
/* circleselect-like modal operators */