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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-04-17 08:53:23 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-04-17 08:53:23 +0400
commit8ee1de2de3418ce66dde97c0aedbacc8a23d1698 (patch)
tree7e48a57929de71ac02a709b37198cf5b425210c3 /source
parent7abc2243b607e23b2daddfc41611a9054318d037 (diff)
text editor reload no-longer resets scroll & cursor - annoying when making tweaks to UI scripts.
also restrict freestyle hack to WITH_FREESTYLE define.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c9
-rw-r--r--source/blender/editors/space_text/text_ops.c41
2 files changed, 32 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 0a4a15cca09..1bae4ec68cc 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2341,8 +2341,13 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time)
/* we tag based on first ID type character to avoid
* looping over all ID's in case there are no tags */
- /* XXX very weak... added check for '27' to ignore freestyle added objects */
- if (id && id->name[2] > 27 && bmain->id_tag_update[id->name[0]]) {
+ if (id &&
+#ifdef WITH_FREESTYLE
+ /* XXX very weak... added check for '27' to ignore freestyle added objects */
+ id->name[2] > 27 &&
+#endif
+ bmain->id_tag_update[id->name[0]])
+ {
updated = 1;
break;
}
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 9af9d3c2674..fec6847bb79 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -69,6 +69,8 @@
#include "text_intern.h"
#include "text_format.h"
+static void txt_screen_clamp(SpaceText *st, ARegion *ar);
+
/************************ poll ***************************/
@@ -319,7 +321,14 @@ void TEXT_OT_open(wmOperatorType *ot)
static int text_reload_exec(bContext *C, wmOperator *op)
{
+ SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
+ ARegion *ar = CTX_wm_region(C);
+
+ /* store view & cursor state */
+ const int orig_top = st->top;
+ const int orig_curl = BLI_findindex(&text->lines, text->curl);
+ const int orig_curc = text->curc;
if (!BKE_text_reload(text)) {
BKE_report(op->reports, RPT_ERROR, "Could not reopen file");
@@ -336,6 +345,12 @@ static int text_reload_exec(bContext *C, wmOperator *op)
text_drawcache_tag_update(CTX_wm_space_text(C), 1);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+ /* return to scroll position */
+ st->top = orig_top;
+ txt_screen_clamp(st, ar);
+ /* return cursor */
+ txt_move_to(text, orig_curl, orig_curc, false);
+
return OPERATOR_FINISHED;
}
@@ -2053,18 +2068,19 @@ void TEXT_OT_overwrite_toggle(wmOperatorType *ot)
/******************* scroll operator **********************/
-/* Moves the view vertically by the specified number of lines */
-static void txt_screen_skip(SpaceText *st, ARegion *ar, int lines)
+static void txt_screen_clamp(SpaceText *st, ARegion *ar)
{
int last;
-
- st->top += lines;
-
last = text_get_total_lines(st, ar);
last = last - (st->viewlines / 2);
-
- if (st->top > last) st->top = last;
- if (st->top < 0) st->top = 0;
+ CLAMP(st->top, 0, last);
+}
+
+/* Moves the view vertically by the specified number of lines */
+static void txt_screen_skip(SpaceText *st, ARegion *ar, int lines)
+{
+ st->top += lines;
+ txt_screen_clamp(st, ar);
}
/* quick enum for tsc->zone (scroller handles) */
@@ -2179,14 +2195,7 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE:
case MIDDLEMOUSE:
if (ELEM(tsc->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) {
- int last;
-
- st->top += st->viewlines * (tsc->zone == SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1);
-
- last = text_get_total_lines(st, ar);
- last = last - (st->viewlines / 2);
-
- CLAMP(st->top, 0, last);
+ txt_screen_skip(st, ar, st->viewlines * (tsc->zone == SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1));
ED_area_tag_redraw(CTX_wm_area(C));
}