
    L                     n    S r SSKJr  SSKJr  SSKJr  SrS rSS jr	SS jr
S	 rS
 rS rS rS rS rg)z
Key bindings, for scrolling up and down through pages.

This are separate bindings, because GNU readline doesn't have them, but
they are very useful for navigating through long multiline buffers, like in
Vi, Emacs, etc...
    )unicode_literals)find_window_for_buffer_name)range)scroll_forwardscroll_backwardscroll_half_page_upscroll_half_page_downscroll_one_line_upscroll_one_line_downc                 V    [        U R                  U R                  R                  5      $ )z8
Return the `Window` for the currently focussed Buffer.
)r   clicurrent_buffer_nameevents    =lib/third_party/prompt_toolkit/key_binding/bindings/scroll.py_current_window_for_eventr      s     'uyy%))2O2OPP    c                    [        U 5      nU R                  R                  nU(       a  UR                  (       a  UR                  nUR                  nUR
                  nU(       a  US-  nUR                  R                  S-   nSnXuR                  :  a5  UR                  U5      n	X-   U:  a
  X-  nUS-  nOOXuR                  :  a  M5  UR                  R                  US5      Ul        ggg)z
Scroll window down.
      r   N)r   r   current_bufferrender_info
ui_contentwindow_heightdocumentcursor_position_row
line_countget_height_for_linetranslate_row_col_to_indexcursor_position)
r   halfwbinfor   scroll_heightyheightline_heights
             r   r   r      s     	"%(A		  AQ]]}}__
 **aM JJ**Q.'''2215K#m3%Q ''' JJAA!QG+ qr   c                    [        U 5      nU R                  R                  nU(       a  UR                  (       a  UR                  nUR                  nU(       a  US-  n[        SUR                  R                  S-
  5      nSnUS:  a,  UR                  U5      nXx-   U:  a
  Xx-  nUS-  nOOUS:  a  M,  UR                  R                  US5      Ul
        ggg)z
Scroll window up.
r   r   r   N)r   r   r   r   r   maxr   r   r   r   r    )	r   r!   r"   r#   r$   r%   r&   r'   r(   s	            r   r   r   =   s     	"%(A		  AQ]]}} **aM 1::11A56!e2215K#m3%Q !e JJAA!QG) qr   c                     [        U SS9  g)z0
Same as ControlF, but only scroll half a page.
Tr!   N)r   r   s    r   r	   r	   [   s     5t$r   c                     [        U SS9  g)z0
Same as ControlB, but only scroll half a page.
Tr,   N)r   r   s    r   r   r   b   s     E%r   c                     [        U R                  U R                  R                  5      nU R                  R                  nU(       a  UR                  (       a  UR                  nUR
                  UR                  UR                  -
  :  aq  UR                  R                  UR                  R                  ::  a-  U=R                  UR                  R                  5       -  sl        U=R
                  S-  sl        gggg)z
scroll_offset += 1
r   N)r   r   r   r   r   vertical_scrollcontent_heightr   r    r&   configured_scroll_offsetstopr   get_cursor_down_position)r   r"   r#   r$   s       r   r   r   i   s     	$EIIuyy/L/LMA		  A====D  4#6#69K9K#KK''))T-K-K-O-OO%%)L)L)NN%!!Q&!	 L  	r   c                 l   [        U R                  U R                  R                  5      nU R                  R                  nU(       a  UR                  (       a  UR                  nUR
                  S:  a  UR                  UR                  5       5      nUR                  R                  UR                  S-
  U-
  UR                  R                  -
  -
  n[        [        SU5      5       H0  nU=R                  UR                  R!                  5       -  sl        M2     U=R
                  S-  sl        gggg)z
scroll_offset -= 1
r   r   N)r   r   r   r   r   r/   r   first_visible_liner    r&   r   r1   bottomr   r*   r   get_cursor_up_position)r   r"   r#   r$   first_line_height	cursor_up_s          r   r
   r
   |   s     	$EIIuyy/L/LMA		  A====D  1$$($<$<T=T=T=V$W! 0022d6H6H16LO`6`6:6T6T6[6[7\ ]	
 s1i01A%%)J)J)LL% 2 !!Q&! %  	r   c                    [        U 5      nU R                  R                  nU(       a  UR                  (       a  [	        UR                  R                  5       UR                  S-   5      nX1l        UR                  R                  US5      Ul	        U=R                  UR                  R                  SS9-  sl	        ggg)zP
Scroll page down. (Prefer the cursor at the top of the page, after scrolling.)
r   r   Tafter_whitespaceN)r   r   r   r   r*   last_visible_liner/   r   r   r    get_start_of_line_positionr   r"   r#   
line_indexs       r   scroll_page_downrB      s     	"%(A		  AQ]]88:A<M<MPQ<QR
&JJAA*aP	QZZBBTXBYY qr   c                    [        U 5      nU R                  R                  nU(       a  UR                  (       a  [	        S[        UR                  R                  5       UR                  R                  S-
  5      5      nUR                  R                  US5      Ul
        U=R                  UR                  R                  SS9-  sl
        SUl        ggg)zQ
Scroll page up. (Prefer the cursor at the bottom of the page, after scrolling.)
r   r   Tr<   N)r   r   r   r   r*   minr5   r   r   r   r    r?   r/   r@   s       r   scroll_page_uprE      s     	"%(A		  AQ]] C @ @ B !

 > > BD E
 JJAA*aP	QZZBBTXBYY  qr   N)F)__doc__
__future__r   prompt_toolkit.layout.utilsr   	six.movesr   __all__r   r   r   r	   r   r   r
   rB   rE    r   r   <module>rL      sM    ( C QH>H<%&'&'6Z r   