@@ -73,6 +73,7 @@ def createMenuBar(self):
73
73
self .actionSave = QtWidgets .QAction ("Save" , self )
74
74
self .actionSaveAs = QtWidgets .QAction ("Save As" , self )
75
75
self .actionExport = QtWidgets .QAction ("Export as PNG" , self )
76
+ self .actionDeiCE = QtWidgets .QAction ("De-iCE" , self )
76
77
self .actionExit = QtWidgets .QAction ("Exit" , self )
77
78
78
79
menuEdit = self .menuBar ().addMenu ("Edit" )
@@ -129,6 +130,8 @@ def createMenuBar(self):
129
130
menuFile .addAction (self .actionSaveAs )
130
131
menuFile .addAction (self .actionExport )
131
132
menuFile .addSeparator ()
133
+ menuFile .addAction (self .actionDeiCE )
134
+ menuFile .addSeparator ()
132
135
menuFile .addAction (self .actionExit )
133
136
134
137
menuEdit .addAction (self .actionSize )
@@ -341,6 +344,7 @@ def connectEvents(self):
341
344
self .actionSave .setShortcut (QtGui .QKeySequence .Save )
342
345
self .actionSaveAs .triggered .connect (self .saveFileAs )
343
346
self .actionExport .triggered .connect (self .exportPNG )
347
+ self .actionDeiCE .triggered .connect (self .deiCE )
344
348
345
349
self .actionExit .triggered .connect (self .exit )
346
350
self .actionExit .setShortcut (QtGui .QKeySequence .Quit )
@@ -717,7 +721,7 @@ def newFile(self):
717
721
"""
718
722
Create blank 80x24 document
719
723
"""
720
- self .ansiImage = AnsiImage (self .ansiGraphics )
724
+ self .ansiImage = AnsiImage (self .ansiGraphics , has_autosave = True )
721
725
self .ansiImage .clear_image (80 , 24 )
722
726
723
727
self .undoStack = []
@@ -777,6 +781,13 @@ def exportPNG(self):
777
781
exportFileName = QtWidgets .QFileDialog .getSaveFileName (self , caption = "Export PNG" , filter = "PNG File (*.png)" )[0 ]
778
782
bitmap = self .ansiImage .to_bitmap (transparent = False , cursor = False )
779
783
bitmap .save (exportFileName , "PNG" )
784
+
785
+ def deiCE (self ):
786
+ """
787
+ Remove iCE colors and replace them with closest non-iCE match assuming regular font
788
+ """
789
+ self .ansiImage .deice ()
790
+ self .redisplayAnsi ()
780
791
781
792
def exit (self ):
782
793
"""
@@ -888,33 +899,42 @@ def addUndo(self, operation):
888
899
Add an undo step (and clean out the redo stack)
889
900
"""
890
901
self .undoStack .append (operation )
902
+ self .ansiImage .do_autosave ()
891
903
self .redoStack = []
892
904
893
905
def undo (self ):
894
906
"""
895
907
Undo last action
896
908
"""
897
- if len (self .undoStack ) != 0 :
898
- undoAction = self .undoStack .pop ()
899
- if undoAction [0 ] == - 1 :
900
- undoAction = undoAction [1 ]
901
- self .redoStack .append ((- 1 , self .ansiImage .change_size (undoAction [0 ], undoAction [1 ], undoAction [2 ])))
902
- else :
903
- self .redoStack .append (self .ansiImage .paste (undoAction , x = 0 , y = 0 ))
904
- self .redisplayAnsi ()
909
+ try :
910
+ if len (self .undoStack ) != 0 :
911
+ undoAction = self .undoStack .pop ()
912
+ if undoAction [0 ] == - 1 :
913
+ undoAction = undoAction [1 ]
914
+ self .redoStack .append ((- 1 , self .ansiImage .change_size (undoAction [0 ], undoAction [1 ], undoAction [2 ])))
915
+ else :
916
+ self .redoStack .append (self .ansiImage .paste (undoAction , x = 0 , y = 0 ))
917
+ self .redisplayAnsi ()
918
+ self .ansiImage .do_autosave ()
919
+ except :
920
+ pass
905
921
906
922
def redo (self ):
907
923
"""
908
924
Undo last undo
909
925
"""
910
- if len (self .redoStack ) != 0 :
911
- redoAction = self .redoStack .pop ()
912
- if redoAction [0 ] == - 1 :
913
- redoAction = redoAction [1 ]
914
- self .undoStack .append ((- 1 , self .ansiImage .change_size (redoAction [0 ], redoAction [1 ], redoAction [2 ])))
915
- else :
916
- self .undoStack .append (self .ansiImage .paste (redoAction , x = 0 , y = 0 ))
917
- self .redisplayAnsi ()
926
+ try :
927
+ if len (self .redoStack ) != 0 :
928
+ redoAction = self .redoStack .pop ()
929
+ if redoAction [0 ] == - 1 :
930
+ redoAction = redoAction [1 ]
931
+ self .undoStack .append ((- 1 , self .ansiImage .change_size (redoAction [0 ], redoAction [1 ], redoAction [2 ])))
932
+ else :
933
+ self .undoStack .append (self .ansiImage .paste (redoAction , x = 0 , y = 0 ))
934
+ self .redisplayAnsi ()
935
+ self .ansiImage .do_autosave ()
936
+ except :
937
+ pass
918
938
919
939
def changeTransparent (self ):
920
940
"""
0 commit comments