Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xomachine authored Dec 11, 2020
2 parents d8081d6 + 247b799 commit dc8d20c
Show file tree
Hide file tree
Showing 31 changed files with 1,427 additions and 953 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
run: |
choco install --no-progress --yes --force --source=cygwin gcc-core,libtool,make,wget,pkg-config
choco install --no-progress --yes --force --source=cygwin lua,lua-devel,lua-lpeg,libncurses-devel
echo '::add-path::C:\tools\cygwin\bin'
- name: Setup $PATH
shell: bash
run: echo 'C:\tools\cygwin\bin' >> $GITHUB_PATH

- name: Git configuration
run: |
Expand Down
33 changes: 27 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@

REGEX_SRC ?= text-regex.c

SRC = array.c buffer.c libutf.c main.c map.c \
sam.c text.c text-motions.c text-objects.c text-util.c \
ui-terminal.c view.c vis.c vis-lua.c vis-modes.c vis-motions.c \
vis-operators.c vis-registers.c vis-marks.c vis-prompt.c vis-text-objects.c \
vis-subprocess.c $(REGEX_SRC)
SRC = array.c \
buffer.c \
libutf.c \
main.c \
map.c \
sam.c \
text.c \
text-common.c \
text-io.c \
text-iterator.c \
text-motions.c \
text-objects.c \
text-util.c \
ui-terminal.c \
view.c \
vis.c \
vis-lua.c \
vis-marks.c \
vis-modes.c \
vis-motions.c \
vis-operators.c \
vis-prompt.c \
vis-registers.c \
vis-text-objects.c \
vis-subprocess.c \
$(REGEX_SRC)

ELF = vis vis-menu vis-digraph
EXECUTABLES = $(ELF) vis-clipboard vis-complete vis-open
Expand All @@ -15,7 +36,7 @@ MANUALS = $(EXECUTABLES:=.1)

DOCUMENTATION = LICENSE README.md

VERSION = $(shell git describe --always --dirty 2>/dev/null || echo "v0.6-git")
VERSION = $(shell git describe --always --dirty 2>/dev/null || echo "v0.7-git")

CONFIG_HELP ?= 1
CONFIG_CURSES ?= 1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Vis - Combining Modal Editing with Structural Regular Expressions

[![builds.sr.ht status](https://builds.sr.ht/~martanne/vis.svg)](https://builds.sr.ht/~martanne/vis)
[![builds.sr.ht status](https://builds.sr.ht/~martanne/vis/commits.svg)](https://builds.sr.ht/~martanne/vis/commits?)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/3939/badge.svg)](https://scan.coverity.com/projects/3939)
[![codecov](https://codecov.io/gh/martanne/vis/branch/master/graph/badge.svg)](https://codecov.io/gh/martanne/vis)
[![Documentation Status](https://readthedocs.org/projects/vis/badge/?version=master)](http://vis.readthedocs.io/en/master/?badge=master)
Expand Down
12 changes: 6 additions & 6 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void array_init(Array *arr) {
array_init_sized(arr, sizeof(void*));
}

void array_init_from(Array *arr, Array *from) {
void array_init_from(Array *arr, const Array *from) {
array_init_sized(arr, from->elem_size);
}

Expand Down Expand Up @@ -55,15 +55,15 @@ void array_clear(Array *arr) {
memset(arr->items, 0, arr->count * arr->elem_size);
}

void *array_get(Array *arr, size_t idx) {
void *array_get(const Array *arr, size_t idx) {
if (idx >= arr->len) {
errno = EINVAL;
return NULL;
}
return arr->items + (idx * arr->elem_size);
}

void *array_get_ptr(Array *arr, size_t idx) {
void *array_get_ptr(const Array *arr, size_t idx) {
if (arr->elem_size != sizeof(void*)) {
errno = ENOTSUP;
return NULL;
Expand Down Expand Up @@ -124,11 +124,11 @@ bool array_remove(Array *arr, size_t idx) {
return true;
}

size_t array_length(Array *arr) {
size_t array_length(const Array *arr) {
return arr->len;
}

size_t array_capacity(Array *arr) {
size_t array_capacity(const Array *arr) {
return arr->count;
}

Expand Down Expand Up @@ -165,7 +165,7 @@ void *array_pop(Array *arr) {
return item;
}

void *array_peek(Array *arr) {
void *array_peek(const Array *arr) {
if (arr->len == 0)
return NULL;
return array_get(arr, arr->len - 1);
Expand Down
12 changes: 6 additions & 6 deletions array.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void array_init(Array*);
*/
void array_init_sized(Array*, size_t elem_size);
/** Initialize Array by using the same element size as in ``from``. */
void array_init_from(Array*, Array *from);
void array_init_from(Array*, const Array *from);
/** Release storage space. Reinitializes Array object. */
void array_release(Array*);
/**
Expand All @@ -66,7 +66,7 @@ bool array_reserve(Array*, size_t count);
* of new elements) might invalidate the pointer.
* @endrst
*/
void *array_get(Array*, size_t idx);
void *array_get(const Array*, size_t idx);
/**
* Set array element.
* @rst
Expand All @@ -76,7 +76,7 @@ void *array_get(Array*, size_t idx);
*/
bool array_set(Array*, size_t idx, void *item);
/** Dereference pointer stored in array element. */
void *array_get_ptr(Array*, size_t idx);
void *array_get_ptr(const Array*, size_t idx);
/** Store the address to which ``item`` points to into the array. */
bool array_set_ptr(Array*, size_t idx, void *item);
/** Add element to the end of the array. */
Expand All @@ -91,9 +91,9 @@ bool array_add_ptr(Array*, void *item);
*/
bool array_remove(Array*, size_t idx);
/** Number of elements currently stored in the array. */
size_t array_length(Array*);
size_t array_length(const Array*);
/** Number of elements which can be stored without enlarging the array. */
size_t array_capacity(Array*);
size_t array_capacity(const Array*);
/** Remove all elements with index greater or equal to ``length``, keep allocated memory. */
bool array_truncate(Array*, size_t length);
/**
Expand Down Expand Up @@ -128,6 +128,6 @@ void *array_pop(Array*);
* .. warning:: The same ownership rules as for ``array_get`` apply.
* @endrst
*/
void *array_peek(Array*);
void *array_peek(const Array*);

#endif
1 change: 1 addition & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ static const KeyBinding bindings_visual[] = {
{ "+", ACTION(SELECTIONS_ROTATE_RIGHT) },
{ "<", ALIAS("<vis-operator-shift-left>gv") },
{ ">", ALIAS("<vis-operator-shift-right>gv") },
{ "<C-a>", ACTION(SELECTIONS_NEW_MATCH_ALL) },
{ "<C-b>", ALIAS("<PageUp>") },
{ "<C-c>", ACTION(SELECTIONS_REMOVE_COLUMN) },
{ "<C-d>", ACTION(SELECTIONS_NEXT) },
Expand Down
5 changes: 3 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ OS=$(uname)

case "$OS" in
FreeBSD|DragonFly) CFLAGS_STD="$CFLAGS_STD -D_BSD_SOURCE -D__BSD_VISIBLE=1" ;;
NetBSD) CFLAGS_STD="$CFLAGS_STD -D_NETBSD_SOURCE" ;;
*BSD) CFLAGS_STD="$CFLAGS_STD -D_BSD_SOURCE" ;;
Darwin) CFLAGS_STD="$CFLAGS_STD -D_DARWIN_C_SOURCE" ;;
AIX) CFLAGS_STD="$CFLAGS_STD -D_ALL_SOURCE" ;;
Expand Down Expand Up @@ -309,7 +310,7 @@ int main(int argc, char *argv[]) {
}
EOF

for libcurses in ncursesw ncurses libcurses; do
for libcurses in ncursesw ncurses curses; do
printf " checking for %s... " "$libcurses"

if test "$have_pkgconfig" = "yes" ; then
Expand Down Expand Up @@ -618,7 +619,7 @@ int main(int argc, char *argv[]) {
}
EOF

if $CC $CFLAGS "$tmpc" $LDFLAGS -o "$tmpo" >/dev/null 2>&1; then
if $CC $CFLAGS $CFLAGS_STD "$tmpc" $LDFLAGS -o "$tmpo" >/dev/null 2>&1; then
HAVE_MEMRCHR=1
printf "%s\n" "yes"
else
Expand Down
2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Vis Editor"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.6
PROJECT_NUMBER = 0.7

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
# built documents.
#
# The short X.Y version.
version = '0.6'
version = '0.7'
# The full version, including alpha/beta/rc tags.
release = '0.6'
release = '0.7'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
14 changes: 11 additions & 3 deletions lua/lexers/bash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ local sq_str = l.delimited_range("'", false, true)
local dq_str = l.delimited_range('"')
local ex_str = l.delimited_range('`')
local heredoc = '<<' * P(function(input, index)
local s, e, _, delimiter =
input:find('%-?(["\']?)([%a_][%w_]*)%1[\n\r\f;]+', index)
local s, e, minus, _, delimiter =
input:find('(-?)(["\']?)([%a_][%w_]*)%2[\n\r\f;]+', index)
-- If the starting delimiter of a here-doc begins with "-", then
-- spaces are allowed to come before the closing delimiter.
local close_pattern
if minus == '-' then
close_pattern = '[\n\r\f%s]+'..delimiter..'\n'
else
close_pattern = '[\n\r\f]+'..delimiter..'\n'
end
if s == index and delimiter then
local _, e = input:find('[\n\r\f]+'..delimiter..'\n', e)
local _, e = input:find(close_pattern, e)
return e and e + 1 or #input + 1
end
end)
Expand Down
48 changes: 48 additions & 0 deletions lua/lexers/gemini.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE.
-- Markdown LPeg lexer.
-- Copyright 2020 Haelwenn (lanodan) Monnier <[email protected]>
-- Gemini / Gemtext LPeg lexer.
-- See https://gemini.circumlunar.space/docs/specification.html

local l = require('lexer')
local token, word_match = l.token, l.word_match
local P, R, S = lpeg.P, lpeg.R, lpeg.S

local M = {_NAME = 'gemini'}

local ws = token(l.WHITESPACE, S(' \t')^1 + S('\v\r\n')^1)

local link = token('link', l.starts_line('=>') * l.nonnewline^0)

-- Should only match ``` at start of line
local pre = token('pre', l.delimited_range('```', false, true))

local header = token('h3', l.starts_line('###') * l.nonnewline^0) +
token('h2', l.starts_line('##') * l.nonnewline^0) +
token('h1', l.starts_line('#') * l.nonnewline^0)

local list = token('list', l.starts_line('*') * l.nonnewline^0)

local blockquote = token(l.STRING, l.starts_line('>') * l.nonnewline^0)

M._rules = {
{'header', header},
{'list', list},
{'blockquote', blockquote},
{'pre', pre},
{'whitespace', ws},
{'link', link}
}

local font_size = 10
local hstyle = 'fore:red'
M._tokenstyles = {
h3 = hstyle..',size:'..(font_size + 3),
h2 = hstyle..',size:'..(font_size + 4),
h1 = hstyle..',size:'..(font_size + 5),
pre = l.STYLE_EMBEDDED..',eolfilled',
link = 'underlined',
list = l.STYLE_CONSTANT
}

return M
Loading

0 comments on commit dc8d20c

Please sign in to comment.