Skip to content

Commit 8f3df9c

Browse files
Implemented breakindent option and added soft wrap mark.
1 parent a41f04c commit 8f3df9c

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

pyvim/commands/commands.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,21 @@ def disable_wrap(editor):
624624
" disable line wrapping. "
625625
editor.wrap_lines = False
626626

627+
628+
@set_cmd('breakindent')
629+
@set_cmd('bri')
630+
def enable_breakindent(editor):
631+
" Enable the breakindent option. "
632+
editor.break_indent = True
633+
634+
635+
@set_cmd('nobreakindent')
636+
@set_cmd('nobri')
637+
def disable_breakindent(editor):
638+
" Enable the breakindent option. "
639+
editor.break_indent = False
640+
641+
627642
@set_cmd('mouse')
628643
def enable_mouse(editor):
629644
" Enable mouse . "

pyvim/editor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, config_directory='~/.pyvim', input=None, output=None):
6363
self.scroll_offset = 0 # ':set scrolloff'
6464
self.relative_number = False # ':set relativenumber'
6565
self.wrap_lines = True # ':set wrap'
66+
self.break_indent = False # ':set breakindent'
6667
self.cursorline = False # ':set cursorline'
6768
self.cursorcolumn = False # ':set cursorcolumn'
6869
self.colorcolumn = [] # ':set colorcolumn'. List of integers.

pyvim/layout.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .welcome_message import WELCOME_MESSAGE_TOKENS, WELCOME_MESSAGE_HEIGHT, WELCOME_MESSAGE_WIDTH
2424

2525
import pyvim.window_arrangement as window_arrangement
26+
from functools import partial
2627

2728
import re
2829
import sys
@@ -551,7 +552,8 @@ def wrap_lines():
551552
colorcolumns=(
552553
lambda: [ColorColumn(pos) for pos in self.editor.colorcolumn]),
553554
ignore_content_width=True,
554-
ignore_content_height=True)
555+
ignore_content_height=True,
556+
get_line_prefix=partial(self._get_line_prefix, editor_buffer.buffer))
555557

556558
return HSplit([
557559
window,
@@ -607,6 +609,20 @@ def preview_search():
607609
search_buffer_control=self.search_control,
608610
focus_on_click=True)
609611

612+
def _get_line_prefix(self, buffer, line_number, wrap_count):
613+
if wrap_count > 0:
614+
result = []
615+
616+
# Add 'breakindent' prefix.
617+
if self.editor.break_indent:
618+
line = buffer.document.lines[line_number]
619+
prefix = line[:len(line) - len(line.lstrip())]
620+
result.append(('', prefix))
621+
622+
# Add softwrap mark.
623+
result.append(('class:soft-wrap', '...'))
624+
return result
625+
return ''
610626

611627
class ReportingProcessor(Processor):
612628
"""

pyvim/style.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def generate_built_in_styles():
8787
'completions-toolbar.arrow': 'bg:#aaddaa #000000 bold',
8888
'completions-toolbar completion': 'bg:#aaddaa #000000',
8989
'completions-toolbar current-completion': 'bg:#444444 #ffffff',
90+
91+
# Soft wrap.
92+
'soft-wrap': '#888888',
9093
}
9194

9295

0 commit comments

Comments
 (0)