From d060cf5e03d1c68f6c6751a28d4501099f479528 Mon Sep 17 00:00:00 2001 From: Hannes Weichelt Date: Tue, 4 Jun 2024 15:57:36 +0200 Subject: [PATCH] inserted textual interface in old application class --- src/clingexplaid/__main__.py | 2 +- src/clingexplaid/cli/clingo_app.py | 20 +++++++------------- src/clingexplaid/cli/textual_gui.py | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/clingexplaid/__main__.py b/src/clingexplaid/__main__.py index aea631d..6719b11 100644 --- a/src/clingexplaid/__main__.py +++ b/src/clingexplaid/__main__.py @@ -11,7 +11,7 @@ from .cli.textual_gui import textual_main from .propagators import SolverDecisionPropagator -RUN_TEXTUAL_GUI = True +RUN_TEXTUAL_GUI = False def main() -> None: diff --git a/src/clingexplaid/cli/clingo_app.py b/src/clingexplaid/cli/clingo_app.py index 11e420b..9f6c677 100644 --- a/src/clingexplaid/cli/clingo_app.py +++ b/src/clingexplaid/cli/clingo_app.py @@ -18,6 +18,7 @@ from ..unsat_constraints import UnsatConstraintComputer from ..utils import get_constants_from_arguments from ..utils.logging import BACKGROUND_COLORS, COLORS +from .textual_gui import ClingexplaidTextualApp HYPERLINK_MASK = "\033]8;{};{}\033\\{}\033]8;;\033\\" @@ -308,15 +309,12 @@ def _method_show_decisions( control: clingo.Control, files: List[str], ) -> None: - decision_signatures = set(self._show_decisions_decision_signatures.items()) - dop = DecisionOrderPropagator(signatures=decision_signatures) - control.register_propagator(dop) # type: ignore - for f in files: - control.load(f) - if not files: - control.load("-") - control.ground() - control.solve(on_model=lambda model: self._print_model(model, "├", "│")) + app = ClingexplaidTextualApp( + files=files, + constants={}, + signatures=set(), + ) + app.run() def print_model(self, model: clingo.Model, _) -> None: # type: ignore return @@ -341,10 +339,6 @@ def main(self, control: clingo.Control, files: Sequence[str]) -> None: # special cases where specific pipelines have to be configured elif self.methods == {"mus", "unsat-constraints"}: self.method_functions["mus"](control, files, compute_unsat_constraints=True) - elif self.methods == {"mus", "unsat-constraints", "show-decisions"}: - self.method_functions["mus"](control, files, compute_unsat_constraints=True) - elif self.methods == {"unsat-constraints", "show-decisions"}: - self.method_functions["unsat-constraints"](control, files) else: print( f"METHOD ERROR: the combination of the methods {[f'--{m}' for m in self.methods]} is invalid. " diff --git a/src/clingexplaid/cli/textual_gui.py b/src/clingexplaid/cli/textual_gui.py index c4b398a..bdce5cb 100644 --- a/src/clingexplaid/cli/textual_gui.py +++ b/src/clingexplaid/cli/textual_gui.py @@ -307,7 +307,7 @@ async def on_model(self, model): model.label.stylize("#000000 on #CCCCCC", 0, 7) model.label.stylize("#000000 on #999999", 7, 7 + 2 + len(str(self.model_count))) # add some small sleep time to make ux seem more interactive - await asyncio.sleep(0.5) + await asyncio.sleep(0.1) def on_propagate(self, decisions): for element in decisions: