# HG changeset patch # User Björn Ricks # Date 1354796062 -3600 # Node ID 497ed1991e85d1dec9fd2be9c2843d78784d93b1 # Parent a620eb6e1fb0ee7633f66b8d2e0e1b81ca83e448 Modify project selection The new project selection has two advantages: 1. It's possible to create and run e.g. projects a and aa Therefore it is possible to create a hirarchy again. 2. When inserting the project key only letters for valid projects are accepted. E.g. two projects exists aa and ab. In that case it is not possible to insert ac. Only a will be shown in the footer. diff -r a620eb6e1fb0 -r 497ed1991e85 getan/states.py --- a/getan/states.py Thu Dec 06 13:10:10 2012 +0100 +++ b/getan/states.py Thu Dec 06 13:14:22 2012 +0100 @@ -92,7 +92,7 @@ else: if len(key) > 0 and len(key[0]) == 1: select_proj = SelectProjectState(self.controller, self.view, key[0]) - return select_proj.check_key() + return select_proj.keypress(key) return self @@ -114,7 +114,10 @@ def set_footer_text(self): self.view.set_footer_text("Selecting project from key: %s" % self.proj_keys, "running") - def check_key(self): + def check_key(self, key): + return len(self.controller.find_projects_by_key(key)) > 0 + + def select_project(self): proj = self.controller.project_by_key(self.proj_keys) if proj: self.reset() @@ -136,12 +139,15 @@ self.proj_keys = self.proj_keys[:-1] self.set_footer_text() return self - + if keys.get_enter() in key: + return self.select_project() else: if len(key) > 0 and len(key[0]) == 1: - self.proj_keys += key[0] - self.set_footer_text() - return self.check_key() + proj_key = self.proj_keys + key[0] + if self.check_key(proj_key): + self.proj_keys += key[0] + self.set_footer_text() + return self.select_project() return self class ExitState(ProjectState):