def finalize_command(self, macro): """Does common command finalizing operations""" macro.rebuild_view() replay.Macro().unsaved_changes = True notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg=None, flags=None): mode = self.commander_arg_value(0, 'toggle') self.set_lisnter() # Remember for next time # ----------- if mode == 'start': state = True elif mode == 'stop': state = False else: state = False if self._recording else True self.set_state(state) # notify the button to update notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL) # Do the work # ----------- self.set_lisnter_state(state)
def commander_execute(self, msg, flags): # Stop recording lx.eval('replay.record stop') macro = replay.Macro() # Hack to fix crash bug. macro.select_event_treeview() if not macro.file_path: return if not macro.unsaved_changes: return if modo.dialogs.yesNo(message("MECCO_REPLAY", "REVERT_DIALOG_TITLE"), message("MECCO_REPLAY", "REVERT_FILE_MSG")) == 'yes': # No unsaved changes macro.unsaved_changes = False # Reload saved data macro.parse('open', macro.file_path) # Rebuild treeview macro.rebuild_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def set_lisnter_state_for_built_in(cls, value): if value: lx.eval("!!macro.record true") replay.Macro().start_track_insertions(True) cls._cmd_listner.layoutCreateOrClose = lx.eval( "user.value replay_record_layoutCreateOrClose ?") cls._cmd_listner.set_state(value) else: anyRecordedCommand = cls._cmd_listner.recording_session_data.lastCommand( ) is not None cls._cmd_listner.layoutCreateOrClose = lx.eval( "user.value replay_record_layoutCreateOrClose ?") cls._cmd_listner.set_state(value) lx.eval("!!macro.record false") if anyRecordedCommand: file_path = lx.eval( 'query platformservice alias ? {kit_mecco_replay:}') file_path = os.path.join(file_path, "Replay_built_in.LXM") lx.eval("!!macro.saveRecorded {%s}" % file_path) replay.Macro().start_track_insertions(False) replay.Macro().merge_with_build_in(file_path) replay.Macro().rebuild_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg, flags): macro = replay.Macro() idx = -1 if macro.primary is None: # If there's no primary node, insert at zero idx = len(macro.children) else: # If there's a primary node, insert right after it node = macro.primary while not node.can_insert_after(): node = node.parent idx = node.index + 1 cache = replay.RecordingCache() if len(cache.commands) == 0: return if len(cache.commands) == 1: macro.add_command(command=cache.commands[0], index=idx) if len(cache.commands) > 1: macro.add_block(block=cache.commands, name="", index=idx) macro.unsaved_changes = True idx += 1 macro.select(idx - 1) macro.rebuild_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg, flags): value = self.commander_arg_value(0) name = self.commander_arg_value(1) lx.eval("user.value %s %s" % (name, value)) notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def undo_Reverse(self): macro = replay.Macro() # Undo of executed operation will revert the modifications # so we only need to move primary node one step up macro.node_for_path(self.m_prev_path).selected = True macro.node_for_path(self.m_next_path).selected = False macro.refresh_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def apply(self, actions): """Change colors for each item in actions""" macro = replay.Macro() # Change color of selected nodes for path, color in actions: macro.node_for_path(path).row_color = color # Rebuild view macro.rebuild_view() replay.Macro().unsaved_changes = True notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg, flags): directory = lx.eval('query platformservice alias ? {%s}' % self.commander_arg_value(0)) path = self.commander_arg_value(1) if not path: notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL) return try: lx.eval('replay.runScript {%s}' % path) except: traceback.print_exc()
def reorder(self, indices): """Reorder indices of marco.children for each index pair in indices""" macro = replay.Macro() # change indices for from_idx, to_idx in indices: macro.children[from_idx].index = to_idx # Rebuild view macro.rebuild_view() replay.Macro().unsaved_changes = True notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def toggle(self): """Toggle suppress for each item in paths""" macro = replay.Macro() # Toggle suppress flag of selected nodes for path in self.m_paths: macro.node_for_path( path).direct_suppress = False if macro.node_for_path( path).direct_suppress else True # Rebuild view macro.rebuild_view() replay.Macro().unsaved_changes = True notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def undo_Forward(self): macro = replay.Macro() undo_svc = lx.service.Undo() if undo_svc.State() != lx.symbol.iUNDO_INVALID: # Execute primary command and store indices for undo self.m_prev_path, self.m_next_path = macro.run_next_line() else: # This means undo_Forward is executing second time and user doing redo # operations. In this case since redo of executed operation will do actual # job we only need to move primary node one step down. macro.node_for_path(self.m_next_path).selected = True macro.node_for_path(self.m_prev_path).selected = False macro.refresh_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg, flags): prompt_save = self.commander_arg_value(0, True) # Stop recording lx.eval('replay.record stop') macro = replay.Macro() # Hack to fix crash bug. macro.select_event_treeview() # If content is not empty ask user for save if prompt_save and macro.unsaved_changes and not macro.is_empty: file_path = macro.file_path if file_path is None: file_path = "Untitled" if modo.dialogs.yesNo( message("MECCO_REPLAY", "ASK_FOR_SAVE_DIALOG_TITLE"), message("MECCO_REPLAY", "ASK_FOR_SAVE_DIALOG_MSG")) == 'yes': # If file path is not assigned ask for new file path if macro.file_path is None: file_path = modo.dialogs.customFile(dtype = 'fileSave', title = message("MECCO_REPLAY", "SAVE_DIALOG_TITLE"), \ names = ('LXM',), unames = ('LXM file'), ext=('LXM',)) if file_path is None: return macro.render_LXM(file_path) # No more file path macro.file_path = None macro.file_format = None macro.unsaved_changes = False # Clear current macro macro.clear() # Rebuild treeview macro.rebuild_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg, flags): path = self.commander_args()['path'] path = [int(idx) for idx in path.split(';')] add = self.commander_args()['add'] macro = replay.Macro() if not add: macro.clear_selection() try: macro.node_for_path(path).selected = True except: pass macro.rebuild_view() macro.unsaved_changes = True notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg, flags): # Stop recording lx.eval('replay.record stop') # Open the replay palette lx.eval('layout.createOrClose ReplayPalette {ReplayPalette} true {Replay Palette} width:400 height:600 persistent:true style:palette') # Try to get the path from the command line: input_path = self.commander_arg_value(0) macro = replay.Macro() # Get the path from the user, if not given as argument: if not input_path: input_path = modo.dialogs.customFile( dtype = 'fileOpen', title = message("MECCO_REPLAY", "OPEN_DIALOG_TITLE"), names = macro.import_format_names, unames = macro.import_format_unames, patterns = macro.import_format_patterns, path = self._path ) if input_path is None: return self.__class__._path = input_path # Parse the file in replay.Macro() and rebuild the view: try: macro.parse('open', input_path) # If successfully parsed add to recently-opened lx.eval('replay.fileOpenAddRecent {%s}' % input_path) except Exception as err: lx.out("Error ", str(err)) modo.dialogs.alert(message("MECCO_REPLAY", "OPEN_FILE_FAIL"), message("MECCO_REPLAY", "OPEN_FILE_FAIL_MSG", str(err)), dtype='warning') finally: macro.rebuild_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)
def commander_execute(self, msg, flags): # Stop recording lx.eval('replay.record stop') # Try to get the path from the command line: input_path = self.commander_arg_value(0) macro = replay.Macro() # Get the path from the user, if not given as argument: if not input_path: input_path = modo.dialogs.customFile( dtype='fileOpen', title=message("MECCO_REPLAY", "OPEN_DIALOG_TITLE"), names=macro.import_format_names, unames=macro.import_format_unames, patterns=macro.import_format_patterns, path=self._path) if input_path is None: return self.__class__._path = input_path # Parse the file in replay.Macro() and rebuild the view: try: macro.parse('insert', input_path) replay.Macro().unsaved_changes = True except Exception as err: modo.dialogs.alert(message("MECCO_REPLAY", "OPEN_FILE_FAIL"), message("MECCO_REPLAY", "OPEN_FILE_FAIL_MSG", str(err)), dtype='warning') finally: macro.rebuild_view() notifier = replay.Notifier() notifier.Notify(lx.symbol.fCMDNOTIFY_CHANGE_ALL)