allow BufferLines to be marked as deleted
This commit is contained in:
parent
f8b509ef94
commit
44644dcd56
1 changed files with 5 additions and 2 deletions
|
@ -14,6 +14,7 @@ class BufferLine(object):
|
||||||
method: str
|
method: str
|
||||||
notes: typing.Dict[str, str] = dataclasses.field(
|
notes: typing.Dict[str, str] = dataclasses.field(
|
||||||
default_factory=dict)
|
default_factory=dict)
|
||||||
|
deleted: bool=False
|
||||||
|
|
||||||
class BufferLineMatch(object):
|
class BufferLineMatch(object):
|
||||||
def __init__(self, line: BufferLine, match: str):
|
def __init__(self, line: BufferLine, match: str):
|
||||||
|
@ -30,11 +31,13 @@ class Buffer(object):
|
||||||
def add(self, line: BufferLine):
|
def add(self, line: BufferLine):
|
||||||
self._lines.appendleft(line)
|
self._lines.appendleft(line)
|
||||||
|
|
||||||
def get(self, index: int=0, **kwargs) -> typing.Optional[BufferLine]:
|
def get(self, index: int=0, from_self=True, deleted=False
|
||||||
from_self = kwargs.get("from_self", True)
|
) -> typing.Optional[BufferLine]:
|
||||||
for line in self._lines:
|
for line in self._lines:
|
||||||
if line.from_self and not from_self:
|
if line.from_self and not from_self:
|
||||||
continue
|
continue
|
||||||
|
if line.deleted and not deleted:
|
||||||
|
continue
|
||||||
return line
|
return line
|
||||||
return None
|
return None
|
||||||
def get_all(self, for_user: typing.Optional[str]=None):
|
def get_all(self, for_user: typing.Optional[str]=None):
|
||||||
|
|
Loading…
Reference in a new issue