1if not modules then modules = { } end modules ['luat-fio'] = {
2 version = 1.001,
3 comment = "companion to luat-lib.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local format = string.format
10local concat = table.concat
11
12if not resolvers.initialized() then
13
14 resolvers.reset()
15
16
17
18
19 resolvers.load()
20
21 if callback then
22
23 local findbinfile = resolvers.findbinfile
24 local findtexfile = resolvers.findtexfile
25 local opentexfile = resolvers.opentexfile
26 local register = callbacks.register
27
28 local ioflush = io.flush
29 local ioread = io.read
30 local writenl = texio.writenl
31
32 local function terminal()
33 writenl("\ntex console > ")
34 ioflush()
35 local line = ioread()
36 writenl("")
37 ioflush()
38 return line
39 end
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 local function open_data_file(name)
63 if not name or name == "" then
64 return {
65 reader = terminal,
66 noflines = 1,
67 filename = "context terminal"
68 }
69 else
70 local fullname = findbinfile(name,"tex")
71 if fullname then
72 return opentexfile(fullname)
73 else
74 return false
75 end
76 end
77 end
78
79 local function find_any_file(name)
80 return name
81 end
82
83 register('find_log_file' , find_any_file, true)
84 register('find_format_file', find_any_file, true)
85
86 register('open_data_file' , open_data_file, true)
87
88 end
89
90end
91
92statistics.register("resource resolver", function()
93 local scandata = resolvers.scandata()
94 return format("loadtime %s seconds, %s scans with scantime %s seconds, %s shared scans, %s found files, scanned paths: %s",
95 resolvers.loadtime(),
96 scandata.n,
97 scandata.time,
98 scandata.shared,
99 #resolvers.foundintrees(),
100 #scandata.paths > 0 and concat(scandata.paths," ") or "<none>"
101 )
102end)
103 |