ZyX_I committed 8f70a37

@/table: Posted strdisplaywidth function

Comments (0)

Files changed (2)

              as `aligns' has to `align'.
+4.4.1. strdisplaywidth resource                     *frawor-r-strdisplaywidth*
+Resource `strdisplaywidth' is defined in plugin/frawor/table. It contains 
+either a reference to |strdisplaywidth()| function or emulation of this 
+function for older Vims.
 4.5. base64 resource                                         *frawor-r-base64*
 Resource `base64' is defined in plugin/frawor/base64. It is used for 
     0.1: Added possibility to specify dictionaries in `strfunc' and `func' 
+    0.1: Posted strdisplaywidth function
 vim: ft=help:tw=78


 "▶1 Header
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@/resources': '0.0'}, 0)
+    execute frawor#Setup('0.1', {'@/resources': '0.0'}, 0)
 elseif s:_pluginloaded
 if exists('*strdisplaywidth')
     let s:F.strdisplaywidth=function('strdisplaywidth')
-    function s:F.strdisplaywidth(str, col)
+    function s:F.strdisplaywidth(str, ...)
         let chars=split(a:str, '\v.@=')
-        let curcol=a:col
+        let col=get(a:000, 0, 0)
+        let curcol=col
         for char in chars
             if char[0] is# "\t"
                 let curcol+=(&ts-curcol%&ts)
                             \  charn==0x3000)
-        return curcol-a:col
+        return curcol-col
 "▶1 printstr         :: len, String, col, align, hl → col + :echon
 "▶1 Register resource
 call s:_f.postresource('printtable', s:F.printtable)
+call s:_f.postresource('strdisplaywidth', s:F.strdisplaywidth)
 call frawor#Lockvar(s:, '_pluginloaded')
 " vim: fmr=▶,▲ sw=4 ts=4 sts=4 et tw=80
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.