mirror of
https://github.com/gryf/pythonhelper.git
synced 2025-12-19 12:28:16 +01:00
Deleted non-iterator code. Refactoring complete.
This commit is contained in:
@@ -379,71 +379,6 @@ def vimBufferIterator(vimBuffer):
|
|||||||
for line in vimBuffer:
|
for line in vimBuffer:
|
||||||
yield line + "\n"
|
yield line + "\n"
|
||||||
|
|
||||||
def vimBufferIterator2(vimBuffer):
|
|
||||||
buf = VimReadlineBuffer(vimBuffer)
|
|
||||||
while True:
|
|
||||||
line = buf.readline()
|
|
||||||
if line == '':
|
|
||||||
break
|
|
||||||
yield line
|
|
||||||
|
|
||||||
# class VimReadlineBuffer() {{{
|
|
||||||
class VimReadlineBuffer(object):
|
|
||||||
# DOC {{{
|
|
||||||
"""A simple wrapper class around a Vim buffer that provides the readline
|
|
||||||
method.
|
|
||||||
"""
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
|
|
||||||
# METHODS {{{
|
|
||||||
|
|
||||||
def __init__(self, vimBuffer):
|
|
||||||
# DOC {{{
|
|
||||||
"""Initializes instances of VimReadlineBuffer().
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
|
|
||||||
vimBuffer -- a Vim buffer
|
|
||||||
"""
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# CODE {{{
|
|
||||||
# remember the settings
|
|
||||||
self.vimBuffer = vimBuffer
|
|
||||||
|
|
||||||
# initialize instance attributes {{{
|
|
||||||
self.currentLine = -1
|
|
||||||
self.bufferLines = len(vimBuffer)
|
|
||||||
# }}}
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
|
|
||||||
def readline(self):
|
|
||||||
# DOC {{{
|
|
||||||
"""Returns the next line from the buffer. If the whole buffer has been
|
|
||||||
read, returns an empty string.
|
|
||||||
"""
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# CODE {{{
|
|
||||||
# increase the current line counter
|
|
||||||
self.currentLine += 1
|
|
||||||
|
|
||||||
# tell if we reached beyond the last line {{{
|
|
||||||
if (self.currentLine == self.bufferLines):
|
|
||||||
return ''
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# Vim stores the lines without the newlines, so add one
|
|
||||||
return "%s\n" % (self.vimBuffer[self.currentLine],)
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
|
|
||||||
def getNearestLineIndex(row, tagLineNumbers):
|
def getNearestLineIndex(row, tagLineNumbers):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Returns the index of 'tagLineNumbers' that contains the line nearest to
|
"""Returns the index of 'tagLineNumbers' that contains the line nearest to
|
||||||
|
|||||||
Reference in New Issue
Block a user