def __init__(self, window_controller, serial_data=None): self._current_view = None self.wc = window_controller self.serial_data = serial_data self.projects = KVOList.alloc().init() self.recent = self._suspended_recent = RecentItemStack(20) self.window_settings_loaded = False
def init_with_document(self, document): self = super(TextDocumentView, self).init() self._documents = KVOList.alloc().init() self.id = next(doc_id_gen) self.project = None self.document = document self.text_view = None self.scroll_view = None self.props = KVOProxy(self) if isinstance(document, ak.NSDocument): # HACK this should not be conditional (but it is for tests) self.kvolink = KVOLink([ (document, "properties.indent_mode", self.props, "indent_mode"), (document, "properties.indent_size", self.props, "indent_size"), (document, "properties.newline_mode", self.props, "newline_mode"), (document, "properties.syntaxdef", self.props, "syntaxdef"), (document, "properties.character_encoding", self.props, "character_encoding"), (document, "properties.highlight_selected_text", self.props, "highlight_selected_text"), ]) return self
def __init__(self, app, window_controller, state=None): self.app = app self._current_view = None self.wc = window_controller self.state = state self.command = CommandBar(self, app.text_commander) self.projects = KVOList.alloc().init() self.recent = self._suspended_recent = RecentItemStack(20) self.window_settings_loaded = False
def init(self): self = super(Project, self).init() self.id = doc_id_gen.next() self.name = const.UNTITLED_PROJECT_NAME self.path = None self.expanded = True self.is_dirty = False self._documents = KVOList.alloc().init() self.reset_serial_cache() return self
def init(self): self = super(Project, self).init() self.id = next(doc_id_gen) self.name = const.UNTITLED_PROJECT_NAME self.path = None self.expanded = True self.is_dirty = False self._documents = KVOList.alloc().init() self.closing = False self.reset_serial_cache() return self
def test_kvolist_items(): lst = KVOList.alloc().init() obj = object() ob2 = object() # test KVO methods yield do_kvolist_countOfItems, lst, 0 yield do_kvolist_insertObject_inItemsAtIndex_, lst, obj, 0 yield do_kvolist_countOfItems, lst, 1 yield do_kvolist_objectInItemsAtIndex_, lst, obj, 0 yield do_kvolist_replaceObjectInItemsAtIndex_withObject_, lst, ob2, 0 yield do_kvolist_objectInItemsAtIndex_, lst, ob2, 0 yield do_kvolist_removeObjectFromItemsAtIndex_, lst, 0 yield do_kvolist_countOfItems, lst, 0 # test list convenience methods yield do_kvolist_len, lst, 0 yield do_kvolist_insert, lst, obj, 0 yield do_kvolist_len, lst, 1 yield do_kvolist_getitem, lst, obj, 0 yield do_kvolist_setitem, lst, ob2, 0 yield do_kvolist_append, lst, obj yield do_kvolist_delitem, lst, 1 yield do_kvolist_contains, lst, ob2 yield do_kvolist_not_contains, lst, obj yield do_kvolist_count, lst, obj, 0 yield do_kvolist_count, lst, ob2, 1 yield do_kvolist_extend, lst, [object(), object()] eq_(len(lst), 3) yield do_kvolist_index, lst, ob2, 0 yield do_kvolist_iter, lst yield do_kvolist_remove, lst, ob2 yield do_kvolist_remove_nonexistent, lst, obj yield do_kvolist_pop, lst, 1 yield do_kvolist_pop, lst lst.setItems_([1, 2, 3, 4]) yield do_kvolist_getslice, lst, 1, 3, [2, 3] lst.setItems_([1, 2, 3, 4]) yield do_kvolist_setslice, lst, 1, 3, [5, 6], [1, 5, 6, 4] lst.setItems_([1, 2, 3, 4]) yield do_kvolist_delslice, lst, 1, 3, [1, 4]
def test_kvolist_items(): lst = KVOList.alloc().init() newitems = fn.NSMutableArray.alloc().init() lst.setItems_(newitems) eq_(lst.items(), newitems)
def test_create_kvolist(): lst = KVOList.alloc().init() eq_(len(lst.items()), 0)