You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
deploy: f0e8d44e6e
This commit is contained in:
@@ -313,6 +313,48 @@
|
||||
<a href="#313" id="313">313</a>
|
||||
<a href="#314" id="314">314</a>
|
||||
<a href="#315" id="315">315</a>
|
||||
<a href="#316" id="316">316</a>
|
||||
<a href="#317" id="317">317</a>
|
||||
<a href="#318" id="318">318</a>
|
||||
<a href="#319" id="319">319</a>
|
||||
<a href="#320" id="320">320</a>
|
||||
<a href="#321" id="321">321</a>
|
||||
<a href="#322" id="322">322</a>
|
||||
<a href="#323" id="323">323</a>
|
||||
<a href="#324" id="324">324</a>
|
||||
<a href="#325" id="325">325</a>
|
||||
<a href="#326" id="326">326</a>
|
||||
<a href="#327" id="327">327</a>
|
||||
<a href="#328" id="328">328</a>
|
||||
<a href="#329" id="329">329</a>
|
||||
<a href="#330" id="330">330</a>
|
||||
<a href="#331" id="331">331</a>
|
||||
<a href="#332" id="332">332</a>
|
||||
<a href="#333" id="333">333</a>
|
||||
<a href="#334" id="334">334</a>
|
||||
<a href="#335" id="335">335</a>
|
||||
<a href="#336" id="336">336</a>
|
||||
<a href="#337" id="337">337</a>
|
||||
<a href="#338" id="338">338</a>
|
||||
<a href="#339" id="339">339</a>
|
||||
<a href="#340" id="340">340</a>
|
||||
<a href="#341" id="341">341</a>
|
||||
<a href="#342" id="342">342</a>
|
||||
<a href="#343" id="343">343</a>
|
||||
<a href="#344" id="344">344</a>
|
||||
<a href="#345" id="345">345</a>
|
||||
<a href="#346" id="346">346</a>
|
||||
<a href="#347" id="347">347</a>
|
||||
<a href="#348" id="348">348</a>
|
||||
<a href="#349" id="349">349</a>
|
||||
<a href="#350" id="350">350</a>
|
||||
<a href="#351" id="351">351</a>
|
||||
<a href="#352" id="352">352</a>
|
||||
<a href="#353" id="353">353</a>
|
||||
<a href="#354" id="354">354</a>
|
||||
<a href="#355" id="355">355</a>
|
||||
<a href="#356" id="356">356</a>
|
||||
<a href="#357" id="357">357</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE file
|
||||
@@ -322,6 +364,8 @@
|
||||
// spell-checker:ignore ignbrk brkint ignpar parmrk inpck istrip inlcr igncr icrnl ixoff ixon iuclc ixany imaxbel iutf
|
||||
// spell-checker:ignore opost olcuc ocrnl onlcr onocr onlret ofill ofdel nldly crdly tabdly bsdly vtdly ffdly
|
||||
// spell-checker:ignore isig icanon iexten echoe crterase echok echonl noflsh xcase tostop echoprt prterase echoctl ctlecho echoke crtkill flusho extproc
|
||||
// spell-checker:ignore lnext rprnt susp swtch vdiscard veof veol verase vintr vkill vlnext vquit vreprint vstart vstop vsusp vswtc vwerase werase
|
||||
// spell-checker:ignore sigquit sigtstp
|
||||
|
||||
</span><span class="kw">use </span><span class="kw">crate</span>::Flag;
|
||||
|
||||
@@ -334,7 +378,10 @@
|
||||
target_os = <span class="string">"openbsd"
|
||||
</span>)))]
|
||||
</span><span class="kw">use </span>nix::sys::termios::BaudRate;
|
||||
<span class="kw">use </span>nix::sys::termios::{ControlFlags <span class="kw">as </span>C, InputFlags <span class="kw">as </span>I, LocalFlags <span class="kw">as </span>L, OutputFlags <span class="kw">as </span>O};
|
||||
<span class="kw">use </span>nix::sys::termios::{
|
||||
ControlFlags <span class="kw">as </span>C, InputFlags <span class="kw">as </span>I, LocalFlags <span class="kw">as </span>L, OutputFlags <span class="kw">as </span>O,
|
||||
SpecialCharacterIndices <span class="kw">as </span>S,
|
||||
};
|
||||
|
||||
<span class="kw">pub const </span>CONTROL_FLAGS: <span class="kw-2">&</span>[Flag<C>] = <span class="kw-2">&</span>[
|
||||
Flag::new(<span class="string">"parenb"</span>, C::PARENB),
|
||||
@@ -628,4 +675,41 @@
|
||||
))]
|
||||
</span>(<span class="string">"4000000"</span>, BaudRate::B4000000),
|
||||
];
|
||||
<span class="doccomment">/// Control characters for the stty command.
|
||||
///
|
||||
/// This constant provides a mapping between the names of control characters
|
||||
/// and their corresponding values in the `S` enum.
|
||||
</span><span class="kw">pub const </span>CONTROL_CHARS: <span class="kw-2">&</span>[(<span class="kw-2">&</span>str, S)] = <span class="kw-2">&</span>[
|
||||
<span class="comment">// Sends an interrupt signal (SIGINT).
|
||||
</span>(<span class="string">"intr"</span>, S::VINTR),
|
||||
<span class="comment">// Sends a quit signal (SIGQUIT).
|
||||
</span>(<span class="string">"quit"</span>, S::VQUIT),
|
||||
<span class="comment">// Deletes the last typed character.
|
||||
</span>(<span class="string">"erase"</span>, S::VERASE),
|
||||
<span class="comment">// Deletes the current line.
|
||||
</span>(<span class="string">"kill"</span>, S::VKILL),
|
||||
<span class="comment">// Signals the end of input.
|
||||
</span>(<span class="string">"eof"</span>, S::VEOF),
|
||||
<span class="comment">// Signals the end of line.
|
||||
</span>(<span class="string">"eol"</span>, S::VEOL),
|
||||
<span class="comment">// Alternate end-of-line character.
|
||||
</span>(<span class="string">"eol2"</span>, S::VEOL2),
|
||||
<span class="comment">// Switch character (only on Linux).
|
||||
</span><span class="attr">#[cfg(target_os = <span class="string">"linux"</span>)]
|
||||
</span>(<span class="string">"swtch"</span>, S::VSWTC),
|
||||
<span class="comment">// Starts output after it has been stopped.
|
||||
</span>(<span class="string">"start"</span>, S::VSTART),
|
||||
<span class="comment">// Stops output.
|
||||
</span>(<span class="string">"stop"</span>, S::VSTOP),
|
||||
<span class="comment">// Sends a suspend signal (SIGTSTP).
|
||||
</span>(<span class="string">"susp"</span>, S::VSUSP),
|
||||
<span class="comment">// Reprints the current line.
|
||||
</span>(<span class="string">"rprnt"</span>, S::VREPRINT),
|
||||
<span class="comment">// Deletes the last word typed.
|
||||
</span>(<span class="string">"werase"</span>, S::VWERASE),
|
||||
<span class="comment">// Enters literal mode (next character is taken literally).
|
||||
</span>(<span class="string">"lnext"</span>, S::VLNEXT),
|
||||
<span class="comment">// Discards the current line.
|
||||
</span>(<span class="string">"discard"</span>, S::VDISCARD),
|
||||
];
|
||||
</code></pre></div></section></main></body></html>
|
||||
@@ -464,12 +464,59 @@
|
||||
<a href="#464" id="464">464</a>
|
||||
<a href="#465" id="465">465</a>
|
||||
<a href="#466" id="466">466</a>
|
||||
<a href="#467" id="467">467</a>
|
||||
<a href="#468" id="468">468</a>
|
||||
<a href="#469" id="469">469</a>
|
||||
<a href="#470" id="470">470</a>
|
||||
<a href="#471" id="471">471</a>
|
||||
<a href="#472" id="472">472</a>
|
||||
<a href="#473" id="473">473</a>
|
||||
<a href="#474" id="474">474</a>
|
||||
<a href="#475" id="475">475</a>
|
||||
<a href="#476" id="476">476</a>
|
||||
<a href="#477" id="477">477</a>
|
||||
<a href="#478" id="478">478</a>
|
||||
<a href="#479" id="479">479</a>
|
||||
<a href="#480" id="480">480</a>
|
||||
<a href="#481" id="481">481</a>
|
||||
<a href="#482" id="482">482</a>
|
||||
<a href="#483" id="483">483</a>
|
||||
<a href="#484" id="484">484</a>
|
||||
<a href="#485" id="485">485</a>
|
||||
<a href="#486" id="486">486</a>
|
||||
<a href="#487" id="487">487</a>
|
||||
<a href="#488" id="488">488</a>
|
||||
<a href="#489" id="489">489</a>
|
||||
<a href="#490" id="490">490</a>
|
||||
<a href="#491" id="491">491</a>
|
||||
<a href="#492" id="492">492</a>
|
||||
<a href="#493" id="493">493</a>
|
||||
<a href="#494" id="494">494</a>
|
||||
<a href="#495" id="495">495</a>
|
||||
<a href="#496" id="496">496</a>
|
||||
<a href="#497" id="497">497</a>
|
||||
<a href="#498" id="498">498</a>
|
||||
<a href="#499" id="499">499</a>
|
||||
<a href="#500" id="500">500</a>
|
||||
<a href="#501" id="501">501</a>
|
||||
<a href="#502" id="502">502</a>
|
||||
<a href="#503" id="503">503</a>
|
||||
<a href="#504" id="504">504</a>
|
||||
<a href="#505" id="505">505</a>
|
||||
<a href="#506" id="506">506</a>
|
||||
<a href="#507" id="507">507</a>
|
||||
<a href="#508" id="508">508</a>
|
||||
<a href="#509" id="509">509</a>
|
||||
<a href="#510" id="510">510</a>
|
||||
<a href="#511" id="511">511</a>
|
||||
<a href="#512" id="512">512</a>
|
||||
<a href="#513" id="513">513</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE file
|
||||
// * that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore clocal tcgetattr tcsetattr tcsanow tiocgwinsz tiocswinsz cfgetospeed cfsetospeed ushort
|
||||
// spell-checker:ignore clocal erange tcgetattr tcsetattr tcsanow tiocgwinsz tiocswinsz cfgetospeed cfsetospeed ushort vmin vtime
|
||||
|
||||
</span><span class="kw">mod </span>flags;
|
||||
|
||||
@@ -477,7 +524,7 @@
|
||||
<span class="kw">use </span>nix::libc::{c_ushort, O_NONBLOCK, TIOCGWINSZ, TIOCSWINSZ};
|
||||
<span class="kw">use </span>nix::sys::termios::{
|
||||
cfgetospeed, cfsetospeed, tcgetattr, tcsetattr, ControlFlags, InputFlags, LocalFlags,
|
||||
OutputFlags, Termios,
|
||||
OutputFlags, SpecialCharacterIndices, Termios,
|
||||
};
|
||||
<span class="kw">use </span>nix::{ioctl_read_bad, ioctl_write_ptr_bad};
|
||||
<span class="kw">use </span>std::io::{<span class="self">self</span>, stdout};
|
||||
@@ -496,7 +543,7 @@
|
||||
target_os = <span class="string">"openbsd"
|
||||
</span>)))]
|
||||
</span><span class="kw">use </span>flags::BAUD_RATES;
|
||||
<span class="kw">use </span>flags::{CONTROL_FLAGS, INPUT_FLAGS, LOCAL_FLAGS, OUTPUT_FLAGS};
|
||||
<span class="kw">use </span>flags::{CONTROL_CHARS, CONTROL_FLAGS, INPUT_FLAGS, LOCAL_FLAGS, OUTPUT_FLAGS};
|
||||
|
||||
<span class="kw">const </span>USAGE: <span class="kw-2">&</span>str = <span class="macro">help_usage!</span>(<span class="string">"stty.md"</span>);
|
||||
<span class="kw">const </span>SUMMARY: <span class="kw-2">&</span>str = <span class="macro">help_about!</span>(<span class="string">"stty.md"</span>);
|
||||
@@ -711,6 +758,52 @@
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>control_char_to_string(cc: nix::libc::cc_t) -> nix::Result<String> {
|
||||
<span class="kw">if </span>cc == <span class="number">0 </span>{
|
||||
<span class="kw">return </span><span class="prelude-val">Ok</span>(<span class="string">"<undef>"</span>.to_string());
|
||||
}
|
||||
|
||||
<span class="kw">let </span>(meta_prefix, code) = <span class="kw">if </span>cc >= <span class="number">0x80 </span>{
|
||||
(<span class="string">"M-"</span>, cc - <span class="number">0x80</span>)
|
||||
} <span class="kw">else </span>{
|
||||
(<span class="string">""</span>, cc)
|
||||
};
|
||||
|
||||
<span class="comment">// Determine the '^'-prefix if applicable and character based on the code
|
||||
</span><span class="kw">let </span>(ctrl_prefix, character) = <span class="kw">match </span>code {
|
||||
<span class="comment">// Control characters in ASCII range
|
||||
</span><span class="number">0</span>..=<span class="number">0x1f </span>=> <span class="prelude-val">Ok</span>((<span class="string">"^"</span>, (<span class="string">b'@' </span>+ code) <span class="kw">as </span>char)),
|
||||
<span class="comment">// Printable ASCII characters
|
||||
</span><span class="number">0x20</span>..=<span class="number">0x7e </span>=> <span class="prelude-val">Ok</span>((<span class="string">""</span>, code <span class="kw">as </span>char)),
|
||||
<span class="comment">// DEL character
|
||||
</span><span class="number">0x7f </span>=> <span class="prelude-val">Ok</span>((<span class="string">"^"</span>, <span class="string">'?'</span>)),
|
||||
<span class="comment">// Out of range (above 8 bits)
|
||||
</span><span class="kw">_ </span>=> <span class="prelude-val">Err</span>(nix::errno::Errno::ERANGE),
|
||||
}<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(<span class="macro">format!</span>(<span class="string">"{meta_prefix}{ctrl_prefix}{character}"</span>))
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>print_control_chars(termios: <span class="kw-2">&</span>Termios, opts: <span class="kw-2">&</span>Options) -> nix::Result<()> {
|
||||
<span class="kw">if </span>!opts.all {
|
||||
<span class="comment">// TODO: this branch should print values that differ from defaults
|
||||
</span><span class="kw">return </span><span class="prelude-val">Ok</span>(());
|
||||
}
|
||||
|
||||
<span class="kw">for </span>(text, cc_index) <span class="kw">in </span>CONTROL_CHARS {
|
||||
<span class="macro">print!</span>(
|
||||
<span class="string">"{text} = {}; "</span>,
|
||||
control_char_to_string(termios.control_chars[<span class="kw-2">*</span>cc_index <span class="kw">as </span>usize])<span class="question-mark">?
|
||||
</span>);
|
||||
}
|
||||
<span class="macro">println!</span>(
|
||||
<span class="string">"min = {}; time = {};"</span>,
|
||||
termios.control_chars[SpecialCharacterIndices::VMIN <span class="kw">as </span>usize],
|
||||
termios.control_chars[SpecialCharacterIndices::VTIME <span class="kw">as </span>usize]
|
||||
);
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>print_in_save_format(termios: <span class="kw-2">&</span>Termios) {
|
||||
<span class="macro">print!</span>(
|
||||
<span class="string">"{:x}:{:x}:{:x}:{:x}"</span>,
|
||||
@@ -730,6 +823,7 @@
|
||||
print_in_save_format(termios);
|
||||
} <span class="kw">else </span>{
|
||||
print_terminal_size(termios, opts)<span class="question-mark">?</span>;
|
||||
print_control_chars(termios, opts)<span class="question-mark">?</span>;
|
||||
print_flags(termios, opts, CONTROL_FLAGS);
|
||||
print_flags(termios, opts, INPUT_FLAGS);
|
||||
print_flags(termios, opts, OUTPUT_FLAGS);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user