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>2019-08-01 13:31:57 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-08-01 13:31:57 +0300
commit433eb3f35d5cf3933801027e33399923609c6539 (patch)
treebf1eecf7af214c1b2dc6b78c951eb3457ee41e7b /source/blender/editors/space_text/text_ops.c
parent3a47fbfac520f6a9c0aaef19e351a1a00cb83af5 (diff)
Text: toggle comment operator
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r--source/blender/editors/space_text/text_ops.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 0c180dc150c..95e7d906b11 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -1294,6 +1294,50 @@ void TEXT_OT_uncomment(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Toggle-Comment Operator
+ * \{ */
+
+static int text_toggle_comment_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Text *text = CTX_data_edit_text(C);
+
+ if (txt_has_sel(text)) {
+ text_drawcache_tag_update(CTX_wm_space_text(C), 0);
+
+ ED_text_undo_push_init(C);
+
+ txt_order_cursors(text, false);
+ if (txt_uncomment(text) == false) {
+ txt_comment(text);
+ }
+ text_update_edited(text);
+
+ text_update_cursor_moved(C);
+ WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+void TEXT_OT_toggle_comment(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Toggle Comment";
+ ot->idname = "TEXT_OT_toggle_comment";
+
+ /* api callbacks */
+ ot->exec = text_toggle_comment_exec;
+ ot->poll = text_edit_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Convert Whitespace Operator
* \{ */