2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-14 14:43:08 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-12-14 14:43:08 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-14 14:43:08 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup sptext
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "DNA_text_types.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
#include "BKE_library.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
#include "BKE_screen.h"
|
2012-05-04 16:17:09 +00:00
|
|
|
#include "BKE_text.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "ED_space_api.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2012-12-19 04:02:19 +00:00
|
|
|
#include "text_format.h"
|
|
|
|
|
#include "text_intern.h" /* own include */
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_framebuffer.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
/* ******************** default callbacks for text space ***************** */
|
|
|
|
|
|
2018-04-21 19:30:56 +02:00
|
|
|
static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
|
|
|
|
ARegion *ar;
|
|
|
|
|
SpaceText *stext;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
stext = MEM_callocN(sizeof(SpaceText), "inittext");
|
|
|
|
|
stext->spacetype = SPACE_TEXT;
|
2009-03-02 12:43:54 +00:00
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
stext->lheight = 12;
|
|
|
|
|
stext->tabnumber = 4;
|
|
|
|
|
stext->margin_column = 80;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* header */
|
2012-03-31 04:24:02 +00:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "header for text");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
BLI_addtail(&stext->regionbase, ar);
|
2012-03-31 04:24:02 +00:00
|
|
|
ar->regiontype = RGN_TYPE_HEADER;
|
2018-12-14 09:47:10 +11:00
|
|
|
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
2016-04-19 21:01:55 +02:00
|
|
|
|
|
|
|
|
/* properties region */
|
|
|
|
|
ar = MEM_callocN(sizeof(ARegion), "properties region for text");
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&stext->regionbase, ar);
|
|
|
|
|
ar->regiontype = RGN_TYPE_UI;
|
|
|
|
|
ar->alignment = RGN_ALIGN_LEFT;
|
|
|
|
|
ar->flag = RGN_FLAG_HIDDEN;
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* main region */
|
|
|
|
|
ar = MEM_callocN(sizeof(ARegion), "main region for text");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
BLI_addtail(&stext->regionbase, ar);
|
2012-03-31 04:24:02 +00:00
|
|
|
ar->regiontype = RGN_TYPE_WINDOW;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
return (SpaceLink *)stext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* not spacelink itself */
|
|
|
|
|
static void text_free(SpaceLink *sl)
|
2018-06-04 09:31:30 +02:00
|
|
|
{
|
2012-03-31 04:24:02 +00:00
|
|
|
SpaceText *stext = (SpaceText *) sl;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
stext->text = NULL;
|
2010-10-13 06:06:39 +00:00
|
|
|
text_free_caches(stext);
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* spacetype; init callback */
|
2010-10-16 08:03:28 +00:00
|
|
|
static void text_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SpaceLink *text_duplicate(SpaceLink *sl)
|
|
|
|
|
{
|
2012-03-31 04:24:02 +00:00
|
|
|
SpaceText *stextn = MEM_dupallocN(sl);
|
2010-10-13 06:06:39 +00:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* clear or remove stuff from old */
|
2010-10-13 06:06:39 +00:00
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
stextn->drawcache = NULL; /* space need it's own cache */
|
2010-10-13 06:06:39 +00:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
return (SpaceLink *)stextn;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-04 15:14:57 +02:00
|
|
|
static void text_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
{
|
2012-03-31 04:24:02 +00:00
|
|
|
SpaceText *st = sa->spacedata.first;
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
|
|
|
|
/* context changes */
|
2012-03-31 04:24:02 +00:00
|
|
|
switch (wmn->category) {
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
case NC_TEXT:
|
2010-09-25 13:27:42 +00:00
|
|
|
/* check if active text was changed, no need to redraw if text isn't active
|
2012-05-25 09:51:53 +00:00
|
|
|
* (reference == NULL) means text was unlinked, should update anyway for this
|
2012-03-03 16:31:46 +00:00
|
|
|
* case -- no way to know was text active before unlinking or not */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->reference && wmn->reference != st->text)
|
2010-09-25 13:27:42 +00:00
|
|
|
break;
|
|
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
switch (wmn->data) {
|
2010-09-26 07:07:05 +00:00
|
|
|
case ND_DISPLAY:
|
2011-10-20 00:48:00 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
2010-09-26 07:07:05 +00:00
|
|
|
case ND_CURSOR:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (st->text && st->text == wmn->reference)
|
2014-11-10 20:56:17 +01:00
|
|
|
text_scroll_to_cursor__area(st, sa, true);
|
2011-10-20 00:48:00 +00:00
|
|
|
|
2010-09-26 07:07:05 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
switch (wmn->action) {
|
2010-09-25 13:27:42 +00:00
|
|
|
case NA_EDITED:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (st->text) {
|
2010-10-13 06:06:39 +00:00
|
|
|
text_drawcache_tag_update(st, 1);
|
2009-04-22 18:39:44 +00:00
|
|
|
text_update_edited(st->text);
|
2010-10-13 06:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-25 13:27:42 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2017-05-20 14:01:03 +10:00
|
|
|
ATTR_FALLTHROUGH; /* fall down to tag redraw */
|
2010-09-25 13:27:42 +00:00
|
|
|
case NA_ADDED:
|
|
|
|
|
case NA_REMOVED:
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
2011-09-02 09:39:21 +00:00
|
|
|
case NA_SELECTED:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (st->text && st->text == wmn->reference)
|
2014-11-10 20:56:17 +01:00
|
|
|
text_scroll_to_cursor__area(st, sa, true);
|
2011-09-02 09:39:21 +00:00
|
|
|
|
|
|
|
|
break;
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case NC_SPACE:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->data == ND_SPACE_TEXT)
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void text_operatortypes(void)
|
|
|
|
|
{
|
|
|
|
|
WM_operatortype_append(TEXT_OT_new);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_open);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_reload);
|
2009-04-22 18:39:44 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_unlink);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_save);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_save_as);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_make_internal);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_run_script);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_refresh_pyconstraints);
|
|
|
|
|
|
|
|
|
|
WM_operatortype_append(TEXT_OT_paste);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_copy);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_cut);
|
2012-04-29 18:53:43 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_duplicate_line);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
|
|
|
|
WM_operatortype_append(TEXT_OT_convert_whitespace);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_uncomment);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_comment);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_unindent);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_indent);
|
|
|
|
|
|
|
|
|
|
WM_operatortype_append(TEXT_OT_select_line);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_select_all);
|
2011-02-17 19:26:59 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_select_word);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-04 16:17:09 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_move_lines);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
|
|
|
|
WM_operatortype_append(TEXT_OT_jump);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_move);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_move_select);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_delete);
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_overwrite_toggle);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
2011-02-17 18:55:17 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_selection_set);
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_cursor_set);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_scroll);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_scroll_bar);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_line_number);
|
|
|
|
|
|
|
|
|
|
WM_operatortype_append(TEXT_OT_line_break);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_insert);
|
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_properties);
|
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_find);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_find_set_selected);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_replace);
|
|
|
|
|
WM_operatortype_append(TEXT_OT_replace_set_selected);
|
|
|
|
|
|
2013-03-24 13:43:40 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_start_find);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
WM_operatortype_append(TEXT_OT_to_3d_object);
|
|
|
|
|
|
|
|
|
|
WM_operatortype_append(TEXT_OT_resolve_conflict);
|
2012-12-31 15:11:36 +00:00
|
|
|
|
|
|
|
|
WM_operatortype_append(TEXT_OT_autocomplete);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
static void text_keymap(struct wmKeyConfig *keyconf)
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
{
|
2018-11-08 15:59:51 +11:00
|
|
|
WM_keymap_ensure(keyconf, "Text Generic", SPACE_TEXT, 0);
|
|
|
|
|
WM_keymap_ensure(keyconf, "Text", SPACE_TEXT, 0);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-15 14:38:43 +00:00
|
|
|
const char *text_context_dir[] = {"edit_text", NULL};
|
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
static int text_context(const bContext *C, const char *member, bContextDataResult *result)
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
{
|
2012-03-31 04:24:02 +00:00
|
|
|
SpaceText *st = CTX_wm_space_text(C);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_data_dir(member)) {
|
2011-02-15 14:38:43 +00:00
|
|
|
CTX_data_dir_set(result, text_context_dir);
|
2009-06-20 14:55:28 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "edit_text")) {
|
2009-03-19 19:03:38 +00:00
|
|
|
CTX_data_id_pointer_set(result, &st->text->id);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
/********************* main region ********************/
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void text_main_region_init(wmWindowManager *wm, ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2010-05-10 06:29:34 +00:00
|
|
|
ListBase *lb;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-17 10:25:02 +00:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* own keymap */
|
2018-08-31 13:36:14 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
|
2013-01-15 16:53:52 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2018-08-31 13:36:14 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0);
|
2008-12-14 14:43:08 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-10 06:29:34 +00:00
|
|
|
/* add drop boxes */
|
|
|
|
|
lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-10 06:29:34 +00:00
|
|
|
WM_event_add_dropbox_handler(&ar->handlers, lb);
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void text_main_region_draw(const bContext *C, ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
|
|
|
|
/* draw entirely, view changes should be handled here */
|
2012-03-31 04:24:02 +00:00
|
|
|
SpaceText *st = CTX_wm_space_text(C);
|
2012-10-26 04:14:10 +00:00
|
|
|
//View2D *v2d = &ar->v2d;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* clear and setup matrix */
|
2010-04-06 07:02:16 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_clear(GPU_COLOR_BIT);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
// UI_view2d_view_ortho(v2d);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* data... */
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
draw_text_main(st, ar);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* reset view matrix */
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
// UI_view2d_view_restore(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* scrollers? */
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-06 18:20:59 +01:00
|
|
|
static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
|
2008-12-15 16:54:47 +00:00
|
|
|
{
|
2014-03-06 18:20:59 +01:00
|
|
|
SpaceText *st = sa->spacedata.first;
|
|
|
|
|
int wmcursor = BC_TEXTEDITCURSOR;
|
|
|
|
|
|
2014-03-07 13:28:39 +11:00
|
|
|
if (st->text && BLI_rcti_isect_pt(&st->txtbar, win->eventstate->x - ar->winrct.xmin, st->txtbar.ymin)) {
|
2014-03-06 18:20:59 +01:00
|
|
|
wmcursor = CURSOR_STD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_cursor_set(win, wmcursor);
|
2008-12-15 16:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-09 18:07:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ************* dropboxes ************* */
|
|
|
|
|
|
2018-08-07 10:38:20 +02:00
|
|
|
static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip))
|
2010-05-09 18:07:17 +00:00
|
|
|
{
|
2014-08-11 10:20:01 +10:00
|
|
|
if (drag->type == WM_DRAG_PATH) {
|
|
|
|
|
/* rule might not work? */
|
|
|
|
|
if (ELEM(drag->icon, ICON_FILE_SCRIPT, ICON_FILE_TEXT, ICON_FILE_BLANK)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2010-05-09 18:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void text_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
|
{
|
|
|
|
|
/* copy drag path to properties */
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_set(drop->ptr, "filepath", drag->path);
|
2010-05-09 18:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-07 10:38:20 +02:00
|
|
|
static bool text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip))
|
2013-10-18 17:35:20 +00:00
|
|
|
{
|
2018-08-07 10:57:09 +02:00
|
|
|
return (drag->type == WM_DRAG_ID);
|
2013-10-18 17:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void text_drop_paste(wmDrag *drag, wmDropBox *drop)
|
|
|
|
|
{
|
2014-06-15 12:09:18 +10:00
|
|
|
char *text;
|
2018-08-05 12:14:55 +02:00
|
|
|
ID *id = WM_drag_ID(drag, 0);
|
2014-06-15 12:09:18 +10:00
|
|
|
|
|
|
|
|
/* copy drag path to properties */
|
|
|
|
|
text = RNA_path_full_ID_py(id);
|
|
|
|
|
RNA_string_set(drop->ptr, "text", text);
|
|
|
|
|
MEM_freeN(text);
|
2013-10-18 17:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-09 18:07:17 +00:00
|
|
|
/* this region dropbox definition */
|
|
|
|
|
static void text_dropboxes(void)
|
|
|
|
|
{
|
2012-03-31 04:24:02 +00:00
|
|
|
ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-09 18:07:17 +00:00
|
|
|
WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy);
|
2013-10-18 17:35:20 +00:00
|
|
|
WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste);
|
2010-05-09 18:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************* end drop *********** */
|
|
|
|
|
|
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
/****************** header region ******************/
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void text_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
ED_region_header_init(ar);
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void text_header_region_draw(const bContext *C, ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ED_region_header(C, ar);
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
/****************** properties region ******************/
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void text_properties_region_init(wmWindowManager *wm, ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
2013-01-15 16:53:52 +00:00
|
|
|
wmKeyMap *keymap;
|
|
|
|
|
|
2013-03-22 12:00:29 +00:00
|
|
|
ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
|
|
|
|
|
ED_region_panels_init(wm, ar);
|
|
|
|
|
|
|
|
|
|
/* own keymaps */
|
2018-08-31 13:36:14 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
|
2013-01-15 16:53:52 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void text_properties_region_draw(const bContext *C, ARegion *ar)
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
{
|
2013-03-24 13:43:40 +00:00
|
|
|
SpaceText *st = CTX_wm_space_text(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-06-11 19:30:48 +02:00
|
|
|
ED_region_panels(C, ar);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-24 13:43:40 +00:00
|
|
|
/* this flag trick is make sure buttons have been added already */
|
|
|
|
|
if (st->flags & ST_FIND_ACTIVATE) {
|
2013-11-22 01:35:38 +01:00
|
|
|
if (UI_textbutton_activate_rna(C, ar, st, "find_text")) {
|
2013-03-25 21:31:24 +00:00
|
|
|
/* if the panel was already open we need to do another redraw */
|
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, sa);
|
|
|
|
|
}
|
2013-03-24 13:43:40 +00:00
|
|
|
st->flags &= ~ST_FIND_ACTIVATE;
|
|
|
|
|
}
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
static void text_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
|
|
|
|
|
{
|
|
|
|
|
SpaceText *stext = (SpaceText *)slink;
|
|
|
|
|
|
2016-06-27 17:40:08 +02:00
|
|
|
if (!ELEM(GS(old_id->name), ID_TXT)) {
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((ID *)stext->text == old_id) {
|
|
|
|
|
stext->text = (Text *)new_id;
|
|
|
|
|
id_us_ensure_real(new_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
/********************* registration ********************/
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
|
void ED_spacetype_text(void)
|
|
|
|
|
{
|
2012-03-31 04:24:02 +00:00
|
|
|
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype text");
|
2008-12-14 14:43:08 +00:00
|
|
|
ARegionType *art;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
st->spaceid = SPACE_TEXT;
|
2009-12-19 22:37:51 +00:00
|
|
|
strncpy(st->name, "Text", BKE_ST_MAXNAME);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-31 04:24:02 +00:00
|
|
|
st->new = text_new;
|
|
|
|
|
st->free = text_free;
|
|
|
|
|
st->init = text_init;
|
|
|
|
|
st->duplicate = text_duplicate;
|
|
|
|
|
st->operatortypes = text_operatortypes;
|
|
|
|
|
st->keymap = text_keymap;
|
|
|
|
|
st->listener = text_listener;
|
|
|
|
|
st->context = text_context;
|
2010-05-09 18:07:17 +00:00
|
|
|
st->dropboxes = text_dropboxes;
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
st->id_remap = text_id_remap;
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* regions: main window */
|
2012-03-31 04:24:02 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
2008-12-14 14:43:08 +00:00
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = text_main_region_init;
|
|
|
|
|
art->draw = text_main_region_draw;
|
2012-03-31 04:24:02 +00:00
|
|
|
art->cursor = text_cursor;
|
2014-04-01 11:34:00 +11:00
|
|
|
art->event_cursor = true;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
/* regions: properties */
|
2012-03-31 04:24:02 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
art->regionid = RGN_TYPE_UI;
|
2012-03-31 04:24:02 +00:00
|
|
|
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = text_properties_region_init;
|
|
|
|
|
art->draw = text_properties_region_draw;
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2009-03-29 19:44:39 +00:00
|
|
|
|
|
|
|
|
/* regions: header */
|
2012-03-31 04:24:02 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
2009-03-29 19:44:39 +00:00
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
2012-03-31 04:24:02 +00:00
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = text_header_region_init;
|
|
|
|
|
art->draw = text_header_region_draw;
|
2009-03-29 19:44:39 +00:00
|
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
BKE_spacetype_register(st);
|
2012-12-19 04:02:19 +00:00
|
|
|
|
|
|
|
|
/* register formatters */
|
|
|
|
|
ED_text_format_register_py();
|
2012-12-29 18:25:03 +00:00
|
|
|
ED_text_format_register_osl();
|
2013-01-16 03:43:09 +00:00
|
|
|
ED_text_format_register_lua();
|
2017-05-22 21:53:32 +02:00
|
|
|
ED_text_format_register_pov();
|
|
|
|
|
ED_text_format_register_pov_ini();
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|