Skip to content
Prev Previous commit
Next Next commit
Added IsReadOnly filter.
  • Loading branch information
jonathanslenders committed Aug 13, 2015
commit 2fff9f8aeffb04f362ac3565f8da1cf32e89e010
12 changes: 12 additions & 0 deletions prompt_toolkit/filters/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'IsAborting',
'IsDone',
'IsMultiline',
'IsReadOnly',
'IsReturning',
'RendererHeightIsKnown',
)
Expand Down Expand Up @@ -66,6 +67,17 @@ def __repr__(self):
return 'IsMultiline()'


class IsReadOnly(Filter):
"""
True when the current buffer is read only.
"""
def __call__(self, cli):
return cli.current_buffer.read_only()

def __repr__(self):
return 'IsReadOnly()'


class HasValidationError(Filter):
"""
Current buffer has validation error.
Expand Down