Skip to content

Commit

Permalink
fix #67 fix #68
Browse files Browse the repository at this point in the history
  • Loading branch information
kvichans committed Aug 11, 2017
1 parent 80aa833 commit 90a90b9
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 21 deletions.
8 changes: 6 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Authors:
Andrey Kvichansky (kvichans on github.com)
Version:
'0.9.3 2016-05-16'
'1.3.14 2017-08-11'
'''

from .cd_ext import Command as CommandRLS
Expand Down Expand Up @@ -57,7 +57,11 @@ def rewrap_sel_by_margin(self): return RLS.rewrap_sel_by_margin()
def del_more_spaces(self): return RLS.del_more_spaces()

# Jumps_cmds
def scroll_to_center(self): return RLS.scroll_to_center()
def scroll_to_center(self): return RLS.scroll_to('cen')
def scroll_to_top(self): return RLS.scroll_to('top')
def scroll_to_bottom(self): return RLS.scroll_to('bot')
def scroll_to_left(self): return RLS.scroll_to('lf')
def scroll_to_right(self): return RLS.scroll_to('rt')
def jump_to_matching_bracket(self): return RLS.jump_to_matching_bracket()
def jump_to_next_mod_lines(self): return RLS.jump_to_status_line('mod', 'next', 'bgn')
def jump_to_prev_mod_lines(self): return RLS.jump_to_status_line('mod', 'prev', 'bgn')
Expand Down
55 changes: 38 additions & 17 deletions cd_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Authors:
Andrey Kvichansky (kvichans on github.com)
Version:
'1.3.13 2017-08-11'
'1.3.14 2017-08-11'
ToDo: (see end of file)
'''

Expand Down Expand Up @@ -624,25 +624,46 @@ def set_sel(cSelBgn, rSelBgn, cSelEnd, rSelEnd):
#############################################################
class Jumps_cmds:
@staticmethod
def scroll_to_center():
def scroll_to(place):
#wraped = apx.get_opt('wrap_mode', False, apx.CONFIG_LEV_FILE)
#last_on_top = apx.get_opt('show_last_line_on_top', False)
txt_lines = ed.get_line_count()
old_top_line= ed.get_prop(app.PROP_LINE_TOP) if app.app_api_version()>='1.0.126' else ed.get_top()
scr_lines = ed.get_prop(app.PROP_VISIBLE_LINES)
crt_line = ed.get_carets()[0][1]
if place in ('cen', 'top', 'bot'):
txt_lines = ed.get_line_count()
old_top_line= ed.get_prop(app.PROP_LINE_TOP) if app.app_api_version()>='1.0.126' else ed.get_top()
scr_lines = ed.get_prop(app.PROP_VISIBLE_LINES)
crt_line = ed.get_carets()[0][1]
vert_indent = 2
# vert_indent = abs(apx.get_opt('find_indent_vert', 0))

new_top_line= crt_line - int(scr_lines/2)
new_top_line= max(new_top_line, 0)
new_top_line= min(new_top_line, txt_lines-1)
pass; #LOG and log('cur, old, new, scr={}',(crt_line, old_top_line, new_top_line, scr_lines))
new_top_line= old_top_line
if False:pass
elif place=='cen':
new_top_line= crt_line - int(scr_lines/2)
elif place=='top':
new_top_line= crt_line - vert_indent+1
elif place=='bot':
new_top_line= crt_line - scr_lines + vert_indent
new_top_line= max(new_top_line, 0)
new_top_line= min(new_top_line, txt_lines-1)
pass; #LOG and log('cur, old, new, scr, ind={}',(crt_line, old_top_line, new_top_line, scr_lines, vert_indent))

if new_top_line!=old_top_line:
if app.app_api_version()>='1.0.126':
ed.set_prop(app.PROP_LINE_TOP, str(new_top_line))
else: # old
ed.set_top(new_top_line)
#def scroll_to_center
if new_top_line!=old_top_line:
if app.app_api_version()>='1.0.126':
ed.set_prop(app.PROP_LINE_TOP, str(new_top_line))
else: # old
ed.set_top(new_top_line)

if place in ('lf', 'rt') and 0==apx.get_opt('wrap_mode', 0): # 0: off
# scr_cols = ed.get_prop(app.PROP_VISIBLE_COLUMNS)
shift = apx.get_opt('cuda_ext_horz_scroll_size', 30)
old_lf_col = ed.get_prop(app.PROP_COLUMN_LEFT)

new_lf_col = old_lf_col + (-shift if place=='lf' else shift)
new_lf_col = max(new_lf_col, 0)
pass; #LOG and log('old,new={}',(old_lf_col,new_lf_col))
if new_lf_col!=old_lf_col:
ed.set_prop(app.PROP_COLUMN_LEFT, str(new_lf_col))
#def scroll_to

@staticmethod
def jump_to_matching_bracket():
Expand Down Expand Up @@ -1934,7 +1955,7 @@ def on_key_up(self, ed_self, key, state):
self.CASM_state = ''
self.tid_hist_i = 0

def scroll_to_center(self): return Jumps_cmds.scroll_to_center()
def scroll_to(self, place): return Jumps_cmds.scroll_to(place)
def jump_to_matching_bracket(self): return Jumps_cmds.jump_to_matching_bracket()
def jump_to_status_line(self, status, nx_pr, bgn_end): return Jumps_cmds.jump_to_status_line(status, nx_pr, bgn_end)
def jump_to_line_by_cb(self): return Jumps_cmds.jump_to_line_by_cb()
Expand Down
26 changes: 25 additions & 1 deletion install.inf
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,36 @@ menu=0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Jumps_cmds
[item61]
[item81]
section=commands
caption=CudaExt: Scroll current line to screen center
method=scroll_to_center
menu=0

[item82]
section=commands
caption=CudaExt: Scroll current line to screen top
method=scroll_to_top
menu=0

[item83]
section=commands
caption=CudaExt: Scroll current line to screen bottom
method=scroll_to_bottom
menu=0

[item84]
section=commands
caption=CudaExt: Scroll screen to left
method=scroll_to_left
menu=0

[item85]
section=commands
caption=CudaExt: Scroll screen to right
method=scroll_to_right
menu=0

[item62]
section=commands
caption=CudaExt: Jump to matching bracket
Expand Down
6 changes: 5 additions & 1 deletion readme/history.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1.3.14 (2017-08-11)
added: "Scroll current line to screen top/bottom"
added: "Scroll screen to left/right"

1.3.12 (2017-07-19)
fixed: dont skip punctuation when align paragraphs
added: ask optiopns on first call "Align paragraph***"
added: ask options on first call "Align paragraph***"

1.3.10 (2017-07-18)
added: commands "Go to Beginning/End of Paragraph", "Go to Next/Prev Paragraph"
Expand Down

0 comments on commit 90a90b9

Please sign in to comment.