diff options
author | flavio <fdanesse@gmail.com> | 2013-07-01 23:43:25 (GMT) |
---|---|---|
committer | flavio <fdanesse@gmail.com> | 2013-07-01 23:43:25 (GMT) |
commit | 1b20eb92aa9ab9e08d4bf60b8ac9a43022789090 (patch) | |
tree | 7cdb5b265a44c4e591954146267db530a40e293c /WorkPanel.py | |
parent | 5a21254313ed3440903038cffc85432f58e8acc3 (diff) |
Revert "Chau, Chau, Adios."
This reverts commit 5a21254313ed3440903038cffc85432f58e8acc3.
Diffstat (limited to 'WorkPanel.py')
-rw-r--r-- | WorkPanel.py | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/WorkPanel.py b/WorkPanel.py index 52845fa..f861df4 100644 --- a/WorkPanel.py +++ b/WorkPanel.py @@ -1079,4 +1079,74 @@ class AutoCompletado(GObject.Object, GtkSource.CompletionProvider): * Hacer el auto completado propiamente dicho, trabajando sobre la línea de código que se está editando. """ - + + ### Iterador de texto sobre el código actual. + textiter = self.buffer.get_iter_at_mark(self.buffer.get_insert())# Gtk.TextIter + + ### indice de linea activa. + indice_de_linea_activa = textiter.get_line() + + ### Texto de la linea activa. + texto_de_linea_en_edicion = textiter.get_slice( + self.buffer.get_iter_at_line(indice_de_linea_activa)) + + ### Si hay un punto en la línea. + if "." in texto_de_linea_en_edicion: + + ### Si el punto está en la última palabra. + if "." in texto_de_linea_en_edicion.split()[-1]: + + ### Auto completado se hace sobre "." + if texto_de_linea_en_edicion.endswith("."): + + palabras = texto_de_linea_en_edicion.split() + + if palabras: + ### Importar paquetes y modulos previos + inicio = self.buffer.get_start_iter() + texto = self.buffer.get_text(inicio, textiter, True) + lineas = texto.splitlines() + + imports = [] + + for linea in lineas: + # FIXME: Analizar mejor los casos como ''', """, etc. + if "import " in linea and not linea.startswith("#") and \ + not linea.startswith("\"") and not linea.startswith("'"): + imports.append(linea) + + ### ['import os', 'import sys', 'from os import path'] + ### Esto es [] si auto completado se hace antes de los imports + + ### Auto completado se hace sobre la última palabra + palabra = palabras[-1] + palabra = palabra.split("(")[-1] # Caso: class Ventana(gtk. + + pals = palabra.split(".")[:-1] + imports.append(pals) # ['import os', 'import sys', 'from os import path', ['gtk', 'gdk', '']] + + ### Guardar en un archivo. + self.__set_imports(imports) + + ### Obtener lista para autocompletado. + lista = self.__get_auto_completado() + + opciones = [] + + for item in lista: + opciones.append(GtkSource.CompletionItem.new(item, + item, None, None)) + + context.add_proposals(self, opciones, True) + + else: + # FIXME: Se está autocompletando. + # Esto debe actualizar la lista de opciones disponibles, + # Filtrando en la lista según el texto escrito por el usuario. + text = texto_de_linea_en_edicion.split(".")[-1] + + else: + context.add_proposals(self, [], True) + + else: + context.add_proposals(self, [], True) |