My dotfiles. Period.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "=============================================================================
  2. " $Id: position.vim 520 2012-03-19 18:09:15Z luc.hermitte $
  3. " File: autoload/lh/position.vim {{{1
  4. " Author: Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
  5. " <URL:http://code.google.com/p/lh-vim/>
  6. " License: GPLv3 with exceptions
  7. " <URL:http://code.google.com/p/lh-vim/wiki/License>
  8. " Version: 3.0.0
  9. " Created: 05th Sep 2007
  10. " Last Update: $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (05th Sep 2007)
  11. "------------------------------------------------------------------------
  12. " Description: «description»
  13. "
  14. "------------------------------------------------------------------------
  15. " Installation:
  16. " Drop it into {rtp}/autoload/lh/
  17. " Vim 7+ required.
  18. " History: «history»
  19. " v1.0.0:
  20. " Creation
  21. " v3.0.0: GPLv3
  22. " TODO:
  23. " }}}1
  24. "=============================================================================
  25. "=============================================================================
  26. let s:cpo_save=&cpo
  27. set cpo&vim
  28. "------------------------------------------------------------------------
  29. " ## Functions {{{1
  30. " # Debug {{{2
  31. function! lh#position#verbose(level)
  32. let s:verbose = a:level
  33. endfunction
  34. function! s:Verbose(expr)
  35. if exists('s:verbose') && s:verbose
  36. echomsg a:expr
  37. endif
  38. endfunction
  39. function! lh#position#debug(expr)
  40. return eval(a:expr)
  41. endfunction
  42. "------------------------------------------------------------------------
  43. " # Public {{{2
  44. " Function: lh#position#is_before {{{3
  45. " @param[in] positions as those returned from |getpos()|
  46. " @return whether lhs_pos is before rhs_pos
  47. function! lh#position#is_before(lhs_pos, rhs_pos)
  48. if a:lhs_pos[0] != a:rhs_pos[0]
  49. throw "Positions from incompatible buffers can't be ordered"
  50. endif
  51. "1 test lines
  52. "2 test cols
  53. let before
  54. \ = (a:lhs_pos[1] == a:rhs_pos[1])
  55. \ ? (a:lhs_pos[2] < a:rhs_pos[2])
  56. \ : (a:lhs_pos[1] < a:rhs_pos[1])
  57. return before
  58. endfunction
  59. function! lh#position#IsBefore(lhs_pos, rhs_pos)
  60. return lh#position#is_before(a:lhs_pos, a:rhs_pos)
  61. endfunction
  62. " Function: lh#position#char_at_mark {{{3
  63. " @return the character at a given mark (|mark|)
  64. function! lh#position#char_at_mark(mark)
  65. let c = getline(a:mark)[col(a:mark)-1]
  66. return c
  67. endfunction
  68. function! lh#position#CharAtMark(mark)
  69. return lh#position#char_at_mark(a:mark)
  70. endfunction
  71. " Function: lh#position#char_at_pos {{{3
  72. " @return the character at a given position (|getpos()|)
  73. function! lh#position#char_at_pos(pos)
  74. let c = getline(a:pos[1])[(a:pos[2])-1]
  75. return c
  76. endfunction
  77. function! lh#position#CharAtPos(pos)
  78. return lh#position#char_at_pos(a:pos)
  79. endfunction
  80. " Functions }}}1
  81. "------------------------------------------------------------------------
  82. let &cpo=s:cpo_save
  83. "=============================================================================
  84. " vim600: set fdm=marker: