Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/vital/Data/String.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ dstring({expr}) *Vital.Data.String.dstring()*
lines({str}) *Vital.Data.String.lines()*
Splits into list of strings of each lines of {str}.

strchars({str}) *Vital.Data.String.strchars()*
Returns the number of characters in String {str}.
This is a polyfill of |strchars()| when it was not provided.

contains_multibyte({str}) *Vital.Data.String.contains_multibyte()*
Return Number 1 if String {str} contains a multi-byte character,
otherwise zero.
Expand Down
121 changes: 118 additions & 3 deletions doc/vital/Mapping.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*vital/Mapping.txt* Utilities for mapping.
*vital/Mapping.txt* Utilities for mapping / abbreviation.

Maintainer: tyru <[email protected]>

Expand All @@ -12,14 +12,129 @@ INTERFACE |Vital.Mapping-interface|
==============================================================================
INTRODUCTION *Vital.Mapping-introduction*

*Vital.Mapping* is TODO
*Vital.Mapping* is a utility functions related to |:map|, |:unmap|,
|:abbreviate|, |:unabbreviate| commands.

==============================================================================
INTERFACE *Vital.Mapping-interface*
------------------------------------------------------------------------------
FUNCTIONS *Vital.Mapping-functions*

TODO
*Mapping.execute_abbr_command()*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以下全て、タグに Vital. がないです。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... 修正しました

execute_abbr_command({mode}, {dict}, {lhs}, {rhs})
Execute `get_abbr_command(mode, dict, lhs, rhs)` result.
See |Mapping.get_abbr_command()|.

*Mapping.execute_map_command()*
execute_map_command({mode}, {dict}, {lhs}, {rhs})
Execute `get_map_command(mode, dict, lhs, rhs)` result.
See |Mapping.get_map_command()|.

*Mapping.execute_unmap_command()*
execute_unmap_command({mode}, {dict}, {lhs})
Execute `get_unmap_command(mode, dict, lhs)` result.
See |Mapping.get_unmap_command()|.

*Mapping.get_all_modes()*
get_all_modes()
Returns string which represents all mode characters ("noiclxs").
NOTE: "v" is not contained. Because "x" and "s" already mean "v".

*Mapping.get_all_modes_list()*
get_all_modes_list()
Returns |List| which represents all mode characters.
Same as `split(get_all_modes(), '\zs')` .
See |Mapping.get_all_modes()|.

*Mapping.get_abbr_command()*
get_abbr_command({mode}, {dict}, {lhs}, {rhs})
Constructs |:abbreviate| command string.
{mode} is a character of mode.
{dict} is a |Dictionary| of options.
{lhs} and {rhs} are strings of lhs/rhs of |:map| command.
The options can be created by |Mapping.options_chars2dict()| or
|maparg()|'s return value when {dict} is non-zero.

*Mapping.get_map_command()*
get_map_command({mode}, {dict}, {lhs}, {rhs})
Constructs |:map| command string.
{mode} is a character of mode.
{dict} is a |Dictionary| of options.
{lhs} and {rhs} are strings of lhs/rhs of |:map| command.
The options can be created by |Mapping.options_chars2dict()| or
|maparg()|'s return value when {dict} is non-zero.

*Mapping.get_unabbr_command()*
get_unabbr_command({mode}, {dict}, {lhs})
Constructs |:unabbreviate| command string.
{mode} is a character of mode.
{dict} is a |Dictionary| of options.
{lhs} is a string of lhs of |:map| command.
The options can be created by |Mapping.options_chars2dict()| or
|maparg()|'s return value when {dict} is non-zero.

*Mapping.get_unmap_command()*
get_unmap_command({mode}, {dict}, {lhs})
Constructs |:unabbreviate| command string.
{mode} is a character of mode.
{dict} is a |Dictionary| of options.
{lhs} is a string of lhs of |:map| command.
The options can be created by |Mapping.options_chars2dict()| or
|maparg()|'s return value when {dict} is non-zero.

*Mapping.options_chars2dict()*
options_chars2dict({chars})
{chars} is a string which represents characters of options.
The return value is a |Dictionary| which is same as |maparg()|'s
return value when {dict} is non-zero.

chars key ~
"e" expr
"b" buffer
"s" silent
"S" script
"u" unique
"r" noremap (inverse)
"n" nowait

Example: >
options_chars2dict("bs") = {
"expr": 0,
"buffer": 1,
"silent": 1,
"script": 0,
"unique": 0,
"noremap": 1,
"nowait": 0,
}
<
*Mapping.options_chars2raw()*
options_chars2raw({chars})
Same as `options_dict2raw(options_chars2dict(chars))` .
See |Mapping.options_dict2raw()| and |Mapping.options_chars2dict()|.

Example: >
options_dict2chars('eb') = '<expr><buffer>'
<
*Mapping.options_dict2chars()*
options_dict2chars({dict})
Converts {dict} to characters of options.

Example: >
options_dict2chars({'expr': 1, 'buffer': 1}) = 'eb'
<
*Mapping.options_dict2raw()*
options_dict2raw({dict})
{dict} is a |Dictionary| which represents options.
See |Mapping.options_chars2dict()| for the options.

Example: >
options_dict2raw({'expr': 1, 'buffer': 1}) = '<expr><buffer>'
<
*Mapping.is_mode_char()*
is_mode_char({char})
Returns non-zero if {char} is a character one of
"v", "n", "o", "i", "c", "l", "x", "s".

==============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl
132 changes: 68 additions & 64 deletions doc/vital/Web/URI.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ like_uri({str}) *Vital.Web.URI.like_uri()*

*Vital.Web.URI.new_default_pattern_set()*
new_default_pattern_set()
Returns |Vital.Web.URI-PatternSet|.
Creates a new |Vital.Web.URI-PatternSet| object.

*Vital.Web.URI.clone_pattern_set()*
clone_pattern_set({patternset})
Clones a |Vital.Web.URI-PatternSet| object.

encode({str} [, {char-enc}]) *Vital.Web.URI.encode()*
Encodes {str} to Percent-encoding string.
Expand Down Expand Up @@ -144,70 +148,70 @@ is_path({str})
is_query({str})
is_fragment({str})

Returns non-zero value if {str} has right syntax
for each component. Returns zero otherwise.
Returns non-zero value if {str} has right syntax
for each component. Returns zero otherwise.

*Vital.Web.URI-URI.clone()*
clone()

This method clones a URI object itself. >
let s:URI = vital#{plugin-name}#new().import('Web.URI')
let uri = s:URI.new('http://example.com/')
let copyuri = uri.clone().relative('/a/b/c')
echo uri.to_string()
" => 'http://example.com/'
echo copyuri.to_string()
" => 'http://example.com/a/b/c'
This method clones a URI object itself. >
let s:URI = vital#{plugin-name}#new().import('Web.URI')
let uri = s:URI.new('http://example.com/')
let copyuri = uri.clone().relative('/a/b/c')
echo uri.to_string()
" => 'http://example.com/'
echo copyuri.to_string()
" => 'http://example.com/a/b/c'
<
*Vital.Web.URI-URI.relative()*
relative({reluri})

This method ...
* Calculates a URI from
base URI and relative URI({reluri}).
* Changes the URI object itself (destructive).
* Returns the URI object itself.
* Calls |Vital.Web.URI-URI.relative()| implicitly.

Example: >
let s:URI = vital#{plugin-name}#new().import('Web.URI')
let BASE_URI = 'http://example.com/foo/bar'
let RELATIVE_URI = '../baz'
echo s:URI.new(BASE_URI).relative(RELATIVE_URI).to_string()
" => 'http://example.com/baz'

let BASE_URI = 'http://example.com/foo/bar/'
let RELATIVE_URI = '../baz'
echo s:URI.new(BASE_URI).relative(RELATIVE_URI).to_string()
" => 'http://example.com/foo/baz'
This method ...
* Calculates a URI from
base URI and relative URI({reluri}).
* Changes the URI object itself (destructive).
* Returns the URI object itself.
* Calls |Vital.Web.URI-URI.relative()| implicitly.

Example: >
let s:URI = vital#{plugin-name}#new().import('Web.URI')
let BASE_URI = 'http://example.com/foo/bar'
let RELATIVE_URI = '../baz'
echo s:URI.new(BASE_URI).relative(RELATIVE_URI).to_string()
" => 'http://example.com/baz'

let BASE_URI = 'http://example.com/foo/bar/'
let RELATIVE_URI = '../baz'
echo s:URI.new(BASE_URI).relative(RELATIVE_URI).to_string()
" => 'http://example.com/foo/baz'
<
*Vital.Web.URI-URI.canonicalize()*
canonicalize()

This method ...
* Canonicalizes the URI.
* Changes the URI object itself (destructive).
* Returns the URI object itself.

See Web.URI.* modules for supported schemes.
For example, the following four URIs
becomes equivalent URI (http://example.com/).
* http://example.com
* http://example.com/
* http://example.com:/
* http://example.com:80/

Example: >
let s:URI = vital#{plugin-name}#new().import('Web.URI')
echo s:URI.new('http://example.com:80/').to_string()
" => 'http://example.com/'
This method ...
* Canonicalizes the URI.
* Changes the URI object itself (destructive).
* Returns the URI object itself.

See Web.URI.* modules for supported schemes.
For example, the following four URIs
becomes equivalent URI (http://example.com/).
* http://example.com
* http://example.com/
* http://example.com:/
* http://example.com:80/

Example: >
let s:URI = vital#{plugin-name}#new().import('Web.URI')
echo s:URI.new('http://example.com:80/').to_string()
" => 'http://example.com/'
<
*Vital.Web.URI-URI.default_port()*
default_port()

This method returns the default port for current scheme.
(e.g.: 80 for "http" scheme)
See Web.URI.* modules for supported schemes.
This method returns the default port for current scheme.
(e.g.: 80 for "http" scheme)
See Web.URI.* modules for supported schemes.

------------------------------------------------------------------------------
PATTERNSET OBJECT *Vital.Web.URI-PatternSet*
Expand All @@ -232,28 +236,28 @@ According to RFC3986, URI allows
but these characters often appears in ordinary text.
This code lets the parser ignore these characters. >

let s:LoosePatternSet = s:URI.new_default_pattern_set()
let s:LoosePatternSet = s:URI.new_default_pattern_set()

" Remove "'", "(", ")" from default sub_delims().
function! s:LoosePatternSet.sub_delims() abort
return '[!$&*+,;=]'
endfunction
" Remove "'", "(", ")" from default sub_delims().
function! s:LoosePatternSet.sub_delims() abort
return '[!$&*+,;=]'
endfunction

" Ignore trailing string after URI.
let NONE = []
let ret = URI.new_from_seq_string(
\ 'http://example.com)', NONE, s:LoosePatternSet)
if ret isnot NONE
...
endif
" Ignore trailing string after URI.
let NONE = []
let ret = URI.new_from_seq_string(
\ 'http://example.com)', NONE, s:LoosePatternSet)
if ret isnot NONE
...
endif
<

get({component}) *Vital.Web.URI-PatternSet.get()*

Returns each component definition.
Returns each component definition.
>
let s:PatternSet = s:URI.new_default_pattern_set()
echo s:PatternSet.get('scheme')
let s:PatternSet = s:URI.new_default_pattern_set()
echo s:PatternSet.get('scheme')
<
Listing all customizable components here (alphabetic order).
NOTE: DON'T call these methods directly.
Expand Down
43 changes: 43 additions & 0 deletions doc/vital/Web/URI/HTTP.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
*vital/Web/URI/HTTP.txt* http scheme handler for Web.URI

Maintainer: tyru <[email protected]>

==============================================================================
CONTENTS *Vital.Web.URI.HTTP-contents*

INTRODUCTION |Vital.Web.URI.HTTP-introduction|
INTERFACE |Vital.Web.URI.HTTP-interface|
Functions |Vital.Web.URI.HTTP-functions|

==============================================================================
INTRODUCTION *Vital.Web.URI.HTTP-introduction*

*Vital.Web.URI.HTTP* is a http scheme handler for |Vital.Web.URI|.

==============================================================================
INTERFACE *Vital.Web.URI.HTTP-interface*
------------------------------------------------------------------------------
FUNCTIONS *Vital.Web.URI.HTTP-functions*

canonicalize({uri}) *Vital.Web.URI.HTTP.canonicalize()*
Canonicalizes {uri}. {uri} is a |Vital.Web.URI-URI| object.

* Set '/' to its path if its path is empty
* If its port is the same as a default port of http scheme (80),
make the URI's port empty

For example, the following four URIs are equivalent:
* http://example.com
* http://example.com/
* http://example.com:/
* http://example.com:80/
This function canonicalizes them to http://example.com/ .

ref. https://tools.ietf.org/html/rfc3986#section-6.2.3

default_port()
*Vital.Web.URI.HTTP.default_port()*
Returns a string of a default port of http scheme ("80").

==============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl
Loading