diff options
Diffstat (limited to 'docs/examples/compat.lua.html')
-rw-r--r-- | docs/examples/compat.lua.html | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/docs/examples/compat.lua.html b/docs/examples/compat.lua.html new file mode 100644 index 0000000..a0abafe --- /dev/null +++ b/docs/examples/compat.lua.html | |||
@@ -0,0 +1,119 @@ | |||
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
3 | <html> | ||
4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | ||
5 | <head> | ||
6 | <title>Lua-System docs</title> | ||
7 | <link rel="stylesheet" href="../ldoc.css" type="text/css" /> | ||
8 | </head> | ||
9 | <body> | ||
10 | |||
11 | <div id="container"> | ||
12 | |||
13 | <div id="product"> | ||
14 | <div id="product_logo"></div> | ||
15 | <div id="product_name"><big><b></b></big></div> | ||
16 | <div id="product_description"></div> | ||
17 | </div> <!-- id="product" --> | ||
18 | |||
19 | |||
20 | <div id="main"> | ||
21 | |||
22 | |||
23 | <!-- Menu --> | ||
24 | |||
25 | <div id="navigation"> | ||
26 | <br/> | ||
27 | <h1>Lua-System</h1> | ||
28 | |||
29 | |||
30 | <ul> | ||
31 | <li><a href="../index.html">Index</a></li> | ||
32 | </ul> | ||
33 | |||
34 | |||
35 | |||
36 | <h2>Examples</h2> | ||
37 | <ul class="nowrap"> | ||
38 | <li><strong>compat.lua</strong></li> | ||
39 | <li><a href="../examples/flag_debugging.lua.html">flag_debugging.lua</a></li> | ||
40 | <li><a href="../examples/password_input.lua.html">password_input.lua</a></li> | ||
41 | <li><a href="../examples/read.lua.html">read.lua</a></li> | ||
42 | <li><a href="../examples/readline.lua.html">readline.lua</a></li> | ||
43 | <li><a href="../examples/spinner.lua.html">spinner.lua</a></li> | ||
44 | <li><a href="../examples/spiral_snake.lua.html">spiral_snake.lua</a></li> | ||
45 | <li><a href="../examples/terminalsize.lua.html">terminalsize.lua</a></li> | ||
46 | </ul> | ||
47 | <h2>Modules</h2> | ||
48 | <ul class="nowrap"> | ||
49 | <li><a href="../modules/system.html">system</a></li> | ||
50 | </ul> | ||
51 | <h2>Classes</h2> | ||
52 | <ul class="nowrap"> | ||
53 | <li><a href="../classes/bitflags.html">bitflags</a></li> | ||
54 | </ul> | ||
55 | <h2>Topics</h2> | ||
56 | <ul class=""> | ||
57 | <li><a href="../topics/01-introduction.md.html">1. Introduction</a></li> | ||
58 | <li><a href="../topics/02-development.md.html">2. Development</a></li> | ||
59 | <li><a href="../topics/03-terminal.md.html">3. Terminal functionality</a></li> | ||
60 | <li><a href="../topics/CHANGELOG.md.html">CHANGELOG</a></li> | ||
61 | <li><a href="../topics/LICENSE.md.html">MIT License</a></li> | ||
62 | </ul> | ||
63 | |||
64 | </div> | ||
65 | |||
66 | <div id="content"> | ||
67 | |||
68 | <h2>compat.lua</h2> | ||
69 | <pre> | ||
70 | <span class="comment">-- This example shows how to remove platform differences to create a | ||
71 | </span><span class="comment">-- cross-platform level playing field. | ||
72 | </span> | ||
73 | <span class="keyword">local</span> sys = <span class="global">require</span> <span class="string">"system"</span> | ||
74 | |||
75 | |||
76 | |||
77 | <span class="keyword">if</span> sys.windows <span class="keyword">then</span> | ||
78 | <span class="comment">-- Windows holds multiple copies of environment variables, to ensure <code>getenv</code> | ||
79 | </span> <span class="comment">-- returns what <code>setenv</code> sets we need to use the <a href="../modules/system.html#getenv">system.getenv</a> instead of | ||
80 | </span> <span class="comment">-- <a href="https://www.lua.org/manual/5.4/manual.html#pdf-os.getenv">os.getenv</a>. | ||
81 | </span> <span class="global">os</span>.getenv = sys.getenv <span class="comment">-- luacheck: ignore | ||
82 | </span> | ||
83 | <span class="comment">-- Set console output to UTF-8 encoding. | ||
84 | </span> sys.<span class="function-name">setconsoleoutputcp</span>(sys.CODEPAGE_UTF8) | ||
85 | |||
86 | <span class="comment">-- Set up the terminal to handle ANSI escape sequences on Windows. | ||
87 | </span> <span class="keyword">if</span> sys.<span class="function-name">isatty</span>(<span class="global">io</span>.stdout) <span class="keyword">then</span> | ||
88 | sys.<span class="function-name">setconsoleflags</span>(<span class="global">io</span>.stdout, sys.<span class="function-name">getconsoleflags</span>(<span class="global">io</span>.stdout) + sys.COF_VIRTUAL_TERMINAL_PROCESSING) | ||
89 | <span class="keyword">end</span> | ||
90 | <span class="keyword">if</span> sys.<span class="function-name">isatty</span>(<span class="global">io</span>.stderr) <span class="keyword">then</span> | ||
91 | sys.<span class="function-name">setconsoleflags</span>(<span class="global">io</span>.stderr, sys.<span class="function-name">getconsoleflags</span>(<span class="global">io</span>.stderr) + sys.COF_VIRTUAL_TERMINAL_PROCESSING) | ||
92 | <span class="keyword">end</span> | ||
93 | <span class="keyword">if</span> sys.<span class="function-name">isatty</span>(<span class="global">io</span>.stdin) <span class="keyword">then</span> | ||
94 | sys.<span class="function-name">setconsoleflags</span>(<span class="global">io</span>.stdin, sys.<span class="function-name">getconsoleflags</span>(<span class="global">io</span>.stdout) + sys.ENABLE_VIRTUAL_TERMINAL_INPUT) | ||
95 | <span class="keyword">end</span> | ||
96 | |||
97 | |||
98 | <span class="keyword">else</span> | ||
99 | <span class="comment">-- On Posix, one can set a variable to an empty string, but on Windows, this | ||
100 | </span> <span class="comment">-- will remove the variable from the environment. To make this consistent | ||
101 | </span> <span class="comment">-- across platforms, we will remove the variable from the environment if the | ||
102 | </span> <span class="comment">-- value is an empty string. | ||
103 | </span> <span class="keyword">local</span> old_setenv = sys.setenv | ||
104 | <span class="keyword">function</span> sys.<span class="function-name">setenv</span>(name, value) | ||
105 | <span class="keyword">if</span> value == <span class="string">""</span> <span class="keyword">then</span> value = <span class="keyword">nil</span> <span class="keyword">end</span> | ||
106 | <span class="keyword">return</span> <span class="function-name">old_setenv</span>(name, value) | ||
107 | <span class="keyword">end</span> | ||
108 | <span class="keyword">end</span></pre> | ||
109 | |||
110 | |||
111 | </div> <!-- id="content" --> | ||
112 | </div> <!-- id="main" --> | ||
113 | <div id="about"> | ||
114 | <i>generated by <a href="http://github.com/lunarmodules/LDoc">LDoc 1.5.0</a></i> | ||
115 | <i style="float:right;">Last updated 2024-06-20 23:11:37 </i> | ||
116 | </div> <!-- id="about" --> | ||
117 | </div> <!-- id="container" --> | ||
118 | </body> | ||
119 | </html> | ||