class content: draw_pre = Hook(symbols.ui.win.content.on_draw_pre, Window, Buffer) draw_post = Hook(symbols.ui.win.content.on_draw_post, Window, Buffer) draw_line_pre = Hook(symbols.ui.win.content.on_draw_line_pre, Window, Buffer, symbols.buffer.lineno, Vec.Type(ctypes.c_char)) draw_line_post = Hook(symbols.ui.win.content.on_draw_line_post, Window, Buffer, symbols.buffer.lineno, Vec.Type(ctypes.c_char))
def call(self, args, hook): pyfunct = self.pyfunct() if pyfunct == None: self.free() return argvec = Vec(args, symbols.vec.vec_p) keys = Vec(argvec[0], symbols.io.key_s) pykeys = [] for index in range(len(keys)): k = symbols.vec.item(keys.struct, index) pykeys.append(core.key.KeyFromPtr(k)) pyfunct(pykeys)
class line: change_pre = Hook(symbols.buffer.line.on_change_pre, Buffer, symbols.buffer.lineno, Vec.Type(ctypes.c_char)) change_post = Hook(symbols.buffer.line.on_change_post, Buffer, symbols.buffer.lineno, Vec.Type(ctypes.c_char)) delete_pre = Hook(symbols.buffer.line.on_delete_pre, Buffer, symbols.buffer.lineno) delete_post = Hook(symbols.buffer.line.on_delete_post, Buffer, symbols.buffer.lineno) insert_pre = Hook(symbols.buffer.line.on_insert_pre, Buffer, symbols.buffer.lineno) insert_post = Hook(symbols.buffer.line.on_insert_post, Buffer, symbols.buffer.lineno)
def call(self, args, hook): """Function to be made into a C function pointer. When called, extracts python arguments from its arguments, and uses them to call the python function associated with this class. Arguments: args (vec_p): A pointer to a vector containing arguments for a call to this hook function. hook (hook_p): A pointer to the hook this function is hooked to, (unused in this function). """ # Dereference the weakref pyfunct = self.pyfunct() # If our function has died, free ourselves. This should never happen, as # .free() should have been called from a callback, but whatever, this # class might not have been GC'd. if pyfunct == None: self.free() return # Cast our argument vector to a nice Vec class cargs = Vec(args, ctypes.c_void_p) pyargs = [] # Extract arguments and cast them to their correct types for typ, arg in zip(self.parent.types, cargs): if isinstance(typ, type): if issubclass(typ, (ctypes.Structure, ctypes._SimpleCData)): # If the type is a raw ctype, then our argument is a ptr # to that type, and we dereference it. value = ctypes.cast(arg, ctypes.POINTER(typ)).contents elif issubclass(typ, ctypes._Pointer): value = ctypes.cast(arg, typ) else: value = typ(arg) else: # Otherwise, we simply hand the pointer to the class value = typ(arg) pyargs.append(value) try: pyfunct(*pyargs) except: core.err.traced_new()
Arguments: buf (Buffer): The buffer to change the selected cursor in. """ symbols.cursor.select_last(buf.struct) def delete_selected(buf): """Deletes the currently selected cursor in a buffer. Arguments: buf (Buffer): The buffer to delete the selected cursor in. """ symbols.cursor.free(symbols.cursor.buffer_selected(buf.struct)) snap_blacklist = Vec(symbols.cursor.snap_blacklist, symbols.cursor.cursor_type_p) """A vector of cursor types that the buffer should not scroll to.""" class types: """A class containing C-implemented cursor types.""" point = CursorTypeFromPtr(symbols.cursor.point.type) """A simple cursor type that acts as you'd expect a basic cursor to.""" region = CursorTypeFromPtr(symbols.cursor.region.type) """A cursor type which can select and operate on a region when activated.""" class hooks: spawn = Hook(symbols.cursor.on_spawn, Cursor) free = Hook(symbols.cursor.on_free, Cursor)
def vec(self): return Vec(symbols.buffer.deferline.get_vec(self.struct), ctypes.c_char)
def __setitem__(self, index, vec): if isinstance(vec, (str, bytes)): vec = Vec.from_string(vec) symbols.buffer.set_line(self.struct, index, vec.struct)