Skip to content

Commit

Permalink
inserted textual interface in old application class
Browse files Browse the repository at this point in the history
  • Loading branch information
hweichelt committed Jun 4, 2024
1 parent 54475bd commit d060cf5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/clingexplaid/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 7 additions & 13 deletions src/clingexplaid/cli/clingo_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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\\"

Expand Down Expand Up @@ -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
Expand All @@ -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. "
Expand Down
2 changes: 1 addition & 1 deletion src/clingexplaid/cli/textual_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d060cf5

Please sign in to comment.