From a654aa03287d19b9e1774d3abcbf8fde6485ae43 Mon Sep 17 00:00:00 2001 From: benfry Date: Thu, 2 Mar 2006 15:34:28 +0000 Subject: [PATCH] fixes for 107, properly handle undo/redo setting sketch mod, and set sketch mod on context menu actions --- app/Base.java | 2 +- app/Editor.java | 34 +++++++++++----------------------- app/EditorListener.java | 2 +- app/FindReplace.java | 2 +- app/Sketch.java | 8 +++++--- app/tools/AutoFormat.java | 2 +- build/shared/revisions.txt | 15 +++++++++++++++ core/todo.txt | 1 + todo.txt | 10 ++++++++-- 9 files changed, 44 insertions(+), 32 deletions(-) diff --git a/app/Base.java b/app/Base.java index 66b0c3876..9afdf2923 100644 --- a/app/Base.java +++ b/app/Base.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2004-05 Ben Fry and Casey Reas + Copyright (c) 2004-06 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology This program is free software; you can redistribute it and/or modify diff --git a/app/Editor.java b/app/Editor.java index 5de59f23b..48870bea2 100644 --- a/app/Editor.java +++ b/app/Editor.java @@ -4,7 +4,7 @@ Editor - main editor panel for the processing development environment Part of the Processing project - http://processing.org - Copyright (c) 2004-05 Ben Fry and Casey Reas + Copyright (c) 2004-06 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology This program is free software; you can redistribute it and/or modify @@ -790,7 +790,7 @@ public class Editor extends JFrame item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.cut(); - sketch.setModified(); + sketch.setModified(true); } }); menu.add(item); @@ -807,7 +807,7 @@ public class Editor extends JFrame item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.paste(); - sketch.setModified(); + sketch.setModified(true); } }); menu.add(item); @@ -898,11 +898,17 @@ public class Editor extends JFrame undoItem.setEnabled(true); undoItem.setText(undo.getUndoPresentationName()); putValue(Action.NAME, undo.getUndoPresentationName()); + if (sketch != null) { + sketch.setModified(true); // 0107 + } } else { this.setEnabled(false); undoItem.setEnabled(false); undoItem.setText("Undo"); putValue(Action.NAME, "Undo"); + if (sketch != null) { + sketch.setModified(false); // 0107 + } } } } @@ -927,7 +933,6 @@ public class Editor extends JFrame protected void updateRedoState() { if (undo.canRedo()) { - this.setEnabled(true); redoItem.setEnabled(true); redoItem.setText(undo.getRedoPresentationName()); putValue(Action.NAME, undo.getRedoPresentationName()); @@ -1861,33 +1866,15 @@ public class Editor extends JFrame mess = mess.substring(javaLang.length()); } error(mess); - - //buttons.clearRun(); buttons.clear(); } - /* - public void finished() { - running = false; - buttons.clearRun(); - message("Done."); - } - */ - - public void message(String msg) { status.notice(msg); } - /* - public void messageClear(String msg) { - status.unnotice(msg); - } - */ - - // ................................................................... @@ -1895,7 +1882,6 @@ public class Editor extends JFrame * Returns the edit popup menu. */ class TextAreaPopup extends JPopupMenu { - //protected ReferenceKeys referenceItems = new ReferenceKeys(); String currentDir = System.getProperty("user.dir"); String referenceFile = null; @@ -1910,6 +1896,7 @@ public class Editor extends JFrame cutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.cut(); + sketch.setModified(true); } }); this.add(cutItem); @@ -1926,6 +1913,7 @@ public class Editor extends JFrame item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.paste(); + sketch.setModified(true); } }); this.add(item); diff --git a/app/EditorListener.java b/app/EditorListener.java index ee603ba2e..bb15955c1 100644 --- a/app/EditorListener.java +++ b/app/EditorListener.java @@ -114,7 +114,7 @@ public class EditorListener { if (!editor.sketch.modified) { if ((code == KeyEvent.VK_BACK_SPACE) || (code == KeyEvent.VK_TAB) || (code == KeyEvent.VK_ENTER) || ((c >= 32) && (c < 128))) { - editor.sketch.setModified(); + editor.sketch.setModified(true); } } diff --git a/app/FindReplace.java b/app/FindReplace.java index 791efc107..61c1c3e84 100644 --- a/app/FindReplace.java +++ b/app/FindReplace.java @@ -329,7 +329,7 @@ public class FindReplace extends JFrame implements ActionListener { editor.textarea.setSelectedText(replaceField.getText()); //editor.setSketchModified(true); //editor.sketch.setCurrentModified(true); - editor.sketch.setModified(); + editor.sketch.setModified(true); // don't allow a double replace replaceButton.setEnabled(false); diff --git a/app/Sketch.java b/app/Sketch.java index acd567dde..ac5993de5 100644 --- a/app/Sketch.java +++ b/app/Sketch.java @@ -715,8 +715,10 @@ public class Sketch { /** * Sets the modified value for the code in the frontmost tab. */ - public void setModified() { - current.modified = true; + public void setModified(boolean state) { + //System.out.println("setting modified to " + state); + //new Exception().printStackTrace(); + current.modified = state; calcModified(); } @@ -1092,7 +1094,7 @@ public class Sketch { buffer.append('\n'); buffer.append(editor.getText()); editor.setText(buffer.toString(), 0, 0); // scroll to start - setModified(); + setModified(true); } diff --git a/app/tools/AutoFormat.java b/app/tools/AutoFormat.java index 5d92f7e7b..0c4e265bd 100644 --- a/app/tools/AutoFormat.java +++ b/app/tools/AutoFormat.java @@ -919,7 +919,7 @@ public class AutoFormat { // replace with new bootiful text // selectionEnd hopefully at least in the neighborhood editor.setText(formattedText, selectionEnd, selectionEnd); - editor.sketch.setModified(); + editor.sketch.setModified(true); // warn user if there are too many parens in either direction if (paren != 0) { diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index b8f8e0efb..e48d58d65 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -7,6 +7,21 @@ releases will be super crusty. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +ABOUT REV 0107 - 2 March 2006 + +More tweaks to "Save" to try an iron out further bugs, though these +are more minor than the others. + ++ cut/paste from the context menu (right-click) in the editor wasn't + properly setting a sketch as modified. + ++ set/unset the sketch's modified state as undo happens. + http://dev.processing.org/bugs/show_bug.cgi?id=248 + + +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + ABOUT REV 0106 - 1 March 2006 Fix for another major bug where sketches don't save properly if you diff --git a/core/todo.txt b/core/todo.txt index ca65b86ed..2c0c62837 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -645,6 +645,7 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=127 PGraphicsGL +_ move to new implementation of jsr231 with new classes and launcher _ make a note about the anti-aliasing types in the faq _ y may be flipped in modelX/Y/Z stuff on opengl _ opengl doesn't work in applets diff --git a/todo.txt b/todo.txt index cc260379b..38c9fe375 100644 --- a/todo.txt +++ b/todo.txt @@ -1,8 +1,16 @@ 0107 pde +X fix yet another save bug, context menu paste/cut not setting modified +X undoing to the code's original state won't unset it as "modified" +X http://dev.processing.org/bugs/show_bug.cgi?id=248 +_ fix linux dist script.. not sure what's going on +_ no relative paths, etc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +_ antlr.jar in the classpath will cause trouble.. +_ jogl jar files, or jogl install will cause trouble +_ /System/Library/Extensions or /Library/Extensions _ finish updates for osx and opengl _ http://developer.apple.com/qa/qa2005/qa1295.html @@ -339,8 +347,6 @@ _ http://processing.org/bugs/show_bug.cgi?id=51 _ code coloring is imperfect because it's not based on a parser _ i.e. mousePressed() is red but mouseMoved() is brown _ http://dev.processing.org/bugs/show_bug.cgi?id=113 -_ undoing to the code's original state won't unset it as "modified" -_ http://dev.processing.org/bugs/show_bug.cgi?id=248 PDE / Editor Buttons