patch attached
Cheers,
-- 
Krzysiek

--~--~---------~--~----~------------~-------~--~----~
Yi development mailing list
[email protected]
http://groups.google.com/group/yi-devel
-~----------~----~----~----~------~----~------~--~---

Thu Dec  4 03:51:47 CET 2008  Krzysztof Goj <[EMAIL PROTECTED]>
  * More scrolling
    Normal mode: zz zt zb z. z+ z-
    Insert mode: ^y ^e

New patches:

[More scrolling
Krzysztof Goj <[EMAIL PROTECTED]>**20081204025147
   Normal mode: zz zt zb z. z+ z-
   Insert mode: ^y ^e
] hunk ./Yi/Buffer/HighLevel.hs 307
 scrollByB f n = do h <- askWindow height
                    scrollB $ n * (f h)
 
--- | Same as ScrollByB, but also moves the cursor
+-- | Same as scrollB, but also moves the cursor
+vimScrollB :: Int -> BufferM ()
+vimScrollB n = do scrollB n
+                  lineMoveRel n
+                  return ()
+
+-- | Same as scrollByB, but also moves the cursor
 vimScrollByB :: (Int -> Int) -> Int -> BufferM ()
 vimScrollByB f n = do h <- askWindow height
hunk ./Yi/Buffer/HighLevel.hs 316
-                      scrollB $ n * (f h)
-                      lineMoveRel $ n * (f h)
-                      return ()
+                      vimScrollB $ n * (f h)
+
+-- | Move to middle line in screen
+scrollToCursorB :: BufferM ()
+scrollToCursorB = do
+    (f, i, _, t) <- markLines
+    let m = (f + t) `div` 2
+    scrollB $ i - m
+
+-- | Move cursor to the top of the screen
+scrollCursorToTopB :: BufferM ()
+scrollCursorToTopB = do
+    (f, i, _, t) <- markLines
+    scrollB $ i - f
+
+-- | Move cursor to the bottom of the screen
+scrollCursorToBottomB :: BufferM ()
+scrollCursorToBottomB = do
+    (f, i, _, t) <- markLines
+    scrollB $ i - t
 
 -- | Scroll by n lines.
 scrollB :: Int -> BufferM ()
hunk ./Yi/Buffer/Misc.hs 22
   , curCol
   , sizeB
   , pointB
+  , markLines
   , moveTo
   , lineMoveRel
   , lineUp
hunk ./Yi/Buffer/Misc.hs 650
     p <- pointB
     queryBuffer (lineAt p)
 
+-- | Return line numbers of (from, ins, sel, to) marks
+markLines :: BufferM (Int, Int, Int, Int)
+markLines = do
+    MarkSet from ins sel to <- askMarks
+    f <- getLn from
+    i <- getLn ins
+    s <- getLn sel
+    t <- getLn to
+    return (f, i, s, t)
+        where getLn m = getMarkPointB m >>= pointLine
+              pointLine p = queryBuffer $ lineAt p
+
+
 -- | Go to line number @[EMAIL PROTECTED] @n@ is indexed from 1. Returns the
 -- actual line we went to (which may be not be the requested line,
 -- if it was out of range)
hunk ./Yi/Keymap/Vim.hs 322
         choice $
           [c ?>>! action i | (c,action) <- singleCmdFM ] ++
           [events evs >>! action i | (evs, action) <- multiCmdFM ] ++
+          [events evs >>! action cnt | (evs, action) <- zScrollCmdFM ] ++
           [char 'r' ?>> textChar >>= write . savingPointB . writeN . replicate 
i
           ,pString "gt" >>! nextTabE
           ,pString "gT" >>! previousTabE]
hunk ./Yi/Keymap/Vim.hs 387
          ,(ctrl $ char 'f',    withBuffer . downScreensB)
          ,(ctrl $ char 'u',    withBuffer . vimScrollByB (negate . (`div` 2)))
          ,(ctrl $ char 'd',    withBuffer . vimScrollByB (`div` 2))
+         ,(ctrl $ char 'y',    withBuffer . vimScrollB . negate)
+         ,(ctrl $ char 'e',    withBuffer . vimScrollB)
          ,(ctrl $ char 'g',    const viFileInfo)
          ,(ctrl $ char 'l',    const refreshEditor)
          ,(ctrl $ char 'r',    withBuffer . flip replicateM_ redoB)
hunk ./Yi/Keymap/Vim.hs 469
          ,(map char "==", const $ withBuffer $ adjIndent IncreaseCycle)
          ]
 
+     zScrollCmdFM :: [([Event], Maybe Int -> YiM ())]
+     zScrollCmdFM =
+         [(map char "zz", mayMove scrollToCursorB)
+         ,(map char "z.", mmGoFNS scrollToCursorB)
+         ,(map char "zt", mayMove scrollCursorToTopB)
+         ,(map char "z+", mmGoFNS scrollCursorToTopB)
+         ,(map char "zb", mayMove scrollCursorToBottomB)
+         ,(map char "z-", mmGoFNS scrollCursorToBottomB)]
+             where mayMove :: BufferM () -> Maybe Int -> YiM ()
+                   mayMove scroll cnt = withEditor $ withBuffer0 $ do
+                      case cnt of
+                         Just n -> gotoLn n >> return ()
+                         Nothing -> return ()
+                      scroll
+                   mmGoFNS scroll = mayMove (scroll >> firstNonSpaceB)
+
      -- | So-called 'operators', which take movement actions as arguments.
      --
      -- How do we achive this? We parse a known operator char then parse

Context:

[Vim: less parens.
Nicolas Pouillard <[EMAIL PROTECTED]>**20081203214311
 Ignore-this: 22702b54973afdb5c77d67929452a695
] 
[Vim: ":<int>" also have to go to first non space char.
Nicolas Pouillard <[EMAIL PROTECTED]>**20081203213806
 Ignore-this: 69ee440d16448b21851ddbc06352b37f
] 
[Vim: improve 'G' code.
Nicolas Pouillard <[EMAIL PROTECTED]>**20081203213640
 Ignore-this: 8cbd5f1a5c13ca99bc7dc0404563a147
] 
[Main.hs: M-x ireadMode to just iread
[EMAIL PROTECTED]
 Ignore-this: b307ff52b630f8500f05218d4a5aa5c0
 So I don't need to constantly disambiguate.
] 
[last of the LANGUAGE pragmas
[EMAIL PROTECTED]
 Ignore-this: 8a1bd56c03682e4c9b163a615263af84
 I have cast the extensions field into perdition, and added the missing 
per-file declarations.
] 
[Shim/*: +pragmas, rm unused imports
[EMAIL PROTECTED]
 Ignore-this: eff16eba16ed8e3b98fdfe9420f1ab2b
] 
[fix up Shim/ w/r/t Control.Exception
[EMAIL PROTECTED]
 Ignore-this: 4ec9ae4bafcf9b98c07acd0a6cbab9e
] 
[Shim/; some -Wall cleanup
[EMAIL PROTECTED]
 Ignore-this: bcfe4c1e2d239472e56d08fe0eee0bd4
] 
['gg' and 'G' should go to first non-space char of line
Krzysztof Goj <[EMAIL PROTECTED]>**20081203212353] 
[Vim normal mode: "gg" with count argument
Krzysztof Goj <[EMAIL PROTECTED]>**20081203203817] 
[Add Yi.Region.regionIsEmpty
Nicolas Pouillard <[EMAIL PROTECTED]>**20081203175753
 Ignore-this: c075fd46a14a991d5476770b9faafed7
] 
[Vim: do nothing when cuting/pasting empty regions
Nicolas Pouillard <[EMAIL PROTECTED]>**20081203155544
 Ignore-this: e0b4bc63452e1e2df93b4e3a2a841413
 
 This avoid marking the buffer as unsaved.
] 
[Vim: style, parens, and trailing white-spaces.
Nicolas Pouillard <[EMAIL PROTECTED]>**20081203155350
 Ignore-this: 3d959998aed83292f5fac99a7a8d6f44
] 
[Vim: when leaving insert/replace mode, use moveXorSol 1 instead of leftB
Nicolas Pouillard <[EMAIL PROTECTED]>**20081203155247
 Ignore-this: f2766bc3a75501484a524d241f84e025
] 
[Comments fix
Krzysztof Goj <[EMAIL PROTECTED]>**20081203155512
 - Esc leaves visual mode -- dropping comment
 - Explain and extend a FIXME for S and C
] 
[Behaviour at end of line (BIG PATCH)
Krzysztof Goj <[EMAIL PROTECTED]>**20081203031045
  - Doesn't allow to go to EOL in normal mode
  - Does allow it in other (visual, insert, replace) modes
  - Corrected D, and '$' command
  - cursor moves left after leaving insert and replace mode
 
] 
[Corrected 'x' and 'X' behaviour
Krzysztof Goj <[EMAIL PROTECTED]>**20081203125741
 Now 'x' and 'X' are aliases to dl and dh (as in Vim) -- they cannot delete 
newline character.
] 
[Ctrl+h in insert and replace mode; Ctrl+w in replace mode
Krzysztof Goj <[EMAIL PROTECTED]>**20081203012614] 
[Ctrl+h in Ex mode
Krzysztof Goj <[EMAIL PROTECTED]>**20081203000017] 
[Ctrl+p, Ctrl+n in Ex mode
Krzysztof Goj <[EMAIL PROTECTED]>**20081202235807] 
[Vim visual mode: 's' is synonym to 'c'
Krzysztof Goj <[EMAIL PROTECTED]>**20081202233509] 
[Vim: ctrl+u, ctrl+d scrolling
Krzysztof Goj <[EMAIL PROTECTED]>**20081202231544] 
[Ctrl-t and Ctrl-d in insert mode (indentation)
Krzysztof Goj <[EMAIL PROTECTED]>**20081202223751] 
[Fixed isMakefile: takeBaseName should be takeFileName. Otherwise makefile's 
named like foo.mk would not be recognized.
[EMAIL PROTECTED] 
[Issue 202: indentation and Vim commands
Krzysztof Goj <[EMAIL PROTECTED]>**20081202183446
 Added indentation-awareness to cutRegion, pasteBefore and pasteAfter.
] 
[Better percent move.
Krzysztof Goj <[EMAIL PROTECTED]>**20081202162105] 
[replace all: more helpful message
[EMAIL PROTECTED] 
[fix build
[EMAIL PROTECTED] 
[Better word and WORD motions for Vim keymap.
Krzysztof Goj <[EMAIL PROTECTED]>**20081202132813] 
[doc
[EMAIL PROTECTED] 
[Yi/Users/Gwern.hs: +shorter binding for gotoLn
[EMAIL PROTECTED]
 Ignore-this: 5defc56344c3e1c61bd602d192e06af3
 I find the default Emacs binding of M-g g tedious; why not just M-g?
] 
[doc
[EMAIL PROTECTED] 
[make Accessor instance of Category
[EMAIL PROTECTED] 
[use Control.Category
[EMAIL PROTECTED] 
[Yi.Keymap.Emacs: +standard emacs M-; binding
[EMAIL PROTECTED]
 Ignore-this: 5abf2d7154acfdcce44286f34ec238b9
] 
[update to base>=4; replace all Control.Exception with Control.OldException
[EMAIL PROTECTED]
 Ignore-this: 205b7c23a4ffcc16b8612d0b4edc9352
] 
[better support for vivid colors
[EMAIL PROTECTED] 
[Main.hs: minor indent
[EMAIL PROTECTED]
 Ignore-this: b53fd55beb556c92b6bba9ee4a49cd61
] 
[added C-w and C-u to ex mode
Aleksandar Dimitrov <[EMAIL PROTECTED]>**20081201103414] 
['ZZ' closes window, not editor, 'ZQ' == ':q!'
Aleksandar Dimitrov <[EMAIL PROTECTED]>**20081201103311] 
[bump version number
[EMAIL PROTECTED] 
[TAG 0.5.2
[EMAIL PROTECTED] 
Patch bundle hash:
57aeeaa4de60814f3ea8ec476ee4acfdf15b0cbf

Reply via email to