blob: 0fbfadeafd3312fa0ac04e36ebc80fc4ee5ef06f [file] [log] [blame]
Aliaksei Budaveid33afe12024-08-12 18:37:15 +02001vim9script
2
3# Support sourcing this script from this directory or any other directory in
4# the direct path that leads to the project's root directory.
5const failed_path: string = finddir('failed', getcwd() .. '/**', -1)
6 ->filter(((cwdpath: string) => (_: number, dirpath: string) =>
7 cwdpath =~ '\<syntax\>' || dirpath =~ '\<syntax\>')(getcwd()))
8 ->get(-1, '') .. '/'
9var error: string = null_string
10
11if failed_path == '/'
12 error = 'No such directory: "failed"'
13else
14 const failed_fnames: string = failed_path .. readdir(failed_path,
15 (fname: string) => fname =~ '^.\+\.dump$')
16 ->join(' ' .. failed_path)
17
18 if failed_fnames =~ 'failed/$'
19 error = 'No such file: "*.dump"'
20 else
21 exec ':0argedit ' .. failed_fnames
22 buffers
23 endif
24endif
25
26def Render()
27 const failed_fname: string = bufname()
28 try
29 setlocal suffixesadd=.dump
30 const dumps_fname: string = findfile(
31 fnamemodify(failed_fname, ':p:t'),
32 fnamemodify(failed_fname, ':p:h:h') .. '/dumps')
33 if filereadable(dumps_fname)
34 term_dumpdiff(failed_fname, dumps_fname)
35 else
36 term_dumpload(failed_fname)
37 endif
38 finally
39 exec 'bwipeout ' .. failed_fname
40 endtry
41enddef
42
43# THE FOLLOWING SETTINGS PERTAIN TO "input/" FILES THAT ARE LIKELY TO BE
44# LOADED SIDE BY SIDE WHENEVER BATCHES OF NEW SCREENDUMPS ARE GENERATED.
45
46# Match "LC_ALL=C" of Makefile.
47language C
48
49# Match the settings from term_util.vim#RunVimInTerminal().
50set t_Co=256 background=light
51hi Normal ctermfg=NONE ctermbg=NONE
52
53# Match the settings from runtest.vim#Xtestscript#SetUpVim().
54set display=lastline ruler scrolloff=5 t_ZH= t_ZR=
55
56# Anticipate non-Latin-1 characters in "input/" files.
57set encoding=utf-8 termencoding=utf-8
58
59autocmd_add([{
60 replace: true,
61 group: 'viewdumps',
62 event: 'BufRead',
63 pattern: '*.dump',
64 cmd: 'Render()',
65}])
66
67# Unconditionally help, in case a list of filenames is passed to the command,
68# the first terminal window with its BufRead event.
69silent doautocmd viewdumps BufRead
70
71if error != null_string
72 # Instead of sleeping, fill half a window with blanks and prompt hit-enter.
73 echom error .. repeat("\x20", (winwidth(0) * (winheight(0) / 2) - strlen(error)))
74 error = null_string
75endif
76
77# vim:fdm=syntax:sw=2:ts=8:noet:nolist:nosta: