[geany/geany] 1b338d: Add UNDO_RELOAD action

Arthur Rosenstein git-noreply at xxxxx
Wed Jan 28 14:38:47 UTC 2015


Branch:      refs/heads/master
Author:      Arthur Rosenstein <artros.misc at gmail.com>
Committer:   Arthur Rosenstein <artros.misc at gmail.com>
Date:        Sun, 10 Nov 2013 09:11:36 UTC
Commit:      1b338d9d7dd23c1dc0828408e6687a9b47e94fc1
             https://github.com/geany/geany/commit/1b338d9d7dd23c1dc0828408e6687a9b47e94fc1

Log Message:
-----------
Add UNDO_RELOAD action


Modified Paths:
--------------
    src/document.c
    src/documentprivate.h

Modified: src/document.c
50 lines changed, 49 insertions(+), 1 deletions(-)
===================================================================
@@ -2496,7 +2496,9 @@ void document_undo_clear_stack(GTrashStack **stack)
 		{
 			switch (a->type)
 			{
-				case UNDO_ENCODING: g_free(a->data); break;
+				case UNDO_ENCODING:
+				case UNDO_RELOAD:
+					g_free(a->data); break;
 				default: break;
 			}
 			g_free(a);
@@ -2618,6 +2620,29 @@ void document_undo(GeanyDocument *doc)
 				g_free(action->data);
 				break;
 			}
+			case UNDO_RELOAD:
+			{
+				UndoReloadData *data = (UndoReloadData*)action->data;
+				gint eol_mode = data->eol_mode;
+				guint i;
+
+				/* We reuse 'data' for the redo action, so read the current EOL mode
+				 * into it before proceeding. */
+				data->eol_mode = editor_get_eol_char_mode(doc->editor);
+
+				/* Undo the rest of the actions which are part of the reloading process. */
+				for (i = data->actions_count; i; --i)
+					document_undo(doc);
+
+				/* Restore the previous EOL mode. */
+				sci_set_eol_mode(doc->editor->sci, eol_mode);
+				/* This might affect the status bar and document meny, so update them. */
+				ui_update_statusbar(doc, -1);
+				ui_document_show_hide(doc);
+
+				document_redo_add(doc, UNDO_RELOAD, data);
+				break;
+			}
 			default: break;
 		}
 	}
@@ -2686,6 +2711,29 @@ void document_redo(GeanyDocument *doc)
 				g_free(action->data);
 				break;
 			}
+			case UNDO_RELOAD:
+			{
+				UndoReloadData *data = (UndoReloadData*)action->data;
+				gint eol_mode = data->eol_mode;
+				guint i;
+
+				/* We reuse 'data' for the undo action, so read the current EOL mode
+				 * into it before proceeding. */
+				data->eol_mode = editor_get_eol_char_mode(doc->editor);
+
+				/* Redo the rest of the actions which are part of the reloading process. */
+				for (i = data->actions_count; i; --i)
+					document_redo(doc);
+
+				/* Restore the previous EOL mode. */
+				sci_set_eol_mode(doc->editor->sci, eol_mode);
+				/* This might affect the status bar and document meny, so update them. */
+				ui_update_statusbar(doc, -1);
+				ui_document_show_hide(doc);
+
+				document_undo_add_internal(doc, UNDO_RELOAD, data);
+				break;
+			}
 			default: break;
 		}
 	}


Modified: src/documentprivate.h
8 lines changed, 8 insertions(+), 0 deletions(-)
===================================================================
@@ -31,9 +31,17 @@ enum
 	UNDO_SCINTILLA = 0,
 	UNDO_ENCODING,
 	UNDO_BOM,
+	UNDO_RELOAD,
 	UNDO_ACTIONS_MAX
 };
 
+typedef struct UndoReloadData
+{
+	guint actions_count; /* How many following undo/redo actions need to be applied. */
+	gint eol_mode;       /* End-Of-Line mode before/after reloading. */
+}
+UndoReloadData;
+
 typedef enum
 {
 	FILE_OK,



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list