Skip to content

Commit 5ac2c8c

Browse files
committed
deploy: f0e8d44
1 parent d28cff4 commit 5ac2c8c

File tree

4 files changed

+184
-6
lines changed

4 files changed

+184
-6
lines changed

dev/src/uu_stty/flags.rs.html

+85-1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,48 @@
313313
<a href="#313" id="313">313</a>
314314
<a href="#314" id="314">314</a>
315315
<a href="#315" id="315">315</a>
316+
<a href="#316" id="316">316</a>
317+
<a href="#317" id="317">317</a>
318+
<a href="#318" id="318">318</a>
319+
<a href="#319" id="319">319</a>
320+
<a href="#320" id="320">320</a>
321+
<a href="#321" id="321">321</a>
322+
<a href="#322" id="322">322</a>
323+
<a href="#323" id="323">323</a>
324+
<a href="#324" id="324">324</a>
325+
<a href="#325" id="325">325</a>
326+
<a href="#326" id="326">326</a>
327+
<a href="#327" id="327">327</a>
328+
<a href="#328" id="328">328</a>
329+
<a href="#329" id="329">329</a>
330+
<a href="#330" id="330">330</a>
331+
<a href="#331" id="331">331</a>
332+
<a href="#332" id="332">332</a>
333+
<a href="#333" id="333">333</a>
334+
<a href="#334" id="334">334</a>
335+
<a href="#335" id="335">335</a>
336+
<a href="#336" id="336">336</a>
337+
<a href="#337" id="337">337</a>
338+
<a href="#338" id="338">338</a>
339+
<a href="#339" id="339">339</a>
340+
<a href="#340" id="340">340</a>
341+
<a href="#341" id="341">341</a>
342+
<a href="#342" id="342">342</a>
343+
<a href="#343" id="343">343</a>
344+
<a href="#344" id="344">344</a>
345+
<a href="#345" id="345">345</a>
346+
<a href="#346" id="346">346</a>
347+
<a href="#347" id="347">347</a>
348+
<a href="#348" id="348">348</a>
349+
<a href="#349" id="349">349</a>
350+
<a href="#350" id="350">350</a>
351+
<a href="#351" id="351">351</a>
352+
<a href="#352" id="352">352</a>
353+
<a href="#353" id="353">353</a>
354+
<a href="#354" id="354">354</a>
355+
<a href="#355" id="355">355</a>
356+
<a href="#356" id="356">356</a>
357+
<a href="#357" id="357">357</a>
316358
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
317359
// *
318360
// * For the full copyright and license information, please view the LICENSE file
@@ -322,6 +364,8 @@
322364
// spell-checker:ignore ignbrk brkint ignpar parmrk inpck istrip inlcr igncr icrnl ixoff ixon iuclc ixany imaxbel iutf
323365
// spell-checker:ignore opost olcuc ocrnl onlcr onocr onlret ofill ofdel nldly crdly tabdly bsdly vtdly ffdly
324366
// spell-checker:ignore isig icanon iexten echoe crterase echok echonl noflsh xcase tostop echoprt prterase echoctl ctlecho echoke crtkill flusho extproc
367+
// spell-checker:ignore lnext rprnt susp swtch vdiscard veof veol verase vintr vkill vlnext vquit vreprint vstart vstop vsusp vswtc vwerase werase
368+
// spell-checker:ignore sigquit sigtstp
325369

326370
</span><span class="kw">use </span><span class="kw">crate</span>::Flag;
327371

@@ -334,7 +378,10 @@
334378
target_os = <span class="string">&quot;openbsd&quot;
335379
</span>)))]
336380
</span><span class="kw">use </span>nix::sys::termios::BaudRate;
337-
<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};
381+
<span class="kw">use </span>nix::sys::termios::{
382+
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,
383+
SpecialCharacterIndices <span class="kw">as </span>S,
384+
};
338385

339386
<span class="kw">pub const </span>CONTROL_FLAGS: <span class="kw-2">&amp;</span>[Flag&lt;C&gt;] = <span class="kw-2">&amp;</span>[
340387
Flag::new(<span class="string">&quot;parenb&quot;</span>, C::PARENB),
@@ -628,4 +675,41 @@
628675
))]
629676
</span>(<span class="string">&quot;4000000&quot;</span>, BaudRate::B4000000),
630677
];
678+
<span class="doccomment">/// Control characters for the stty command.
679+
///
680+
/// This constant provides a mapping between the names of control characters
681+
/// and their corresponding values in the `S` enum.
682+
</span><span class="kw">pub const </span>CONTROL_CHARS: <span class="kw-2">&amp;</span>[(<span class="kw-2">&amp;</span>str, S)] = <span class="kw-2">&amp;</span>[
683+
<span class="comment">// Sends an interrupt signal (SIGINT).
684+
</span>(<span class="string">&quot;intr&quot;</span>, S::VINTR),
685+
<span class="comment">// Sends a quit signal (SIGQUIT).
686+
</span>(<span class="string">&quot;quit&quot;</span>, S::VQUIT),
687+
<span class="comment">// Deletes the last typed character.
688+
</span>(<span class="string">&quot;erase&quot;</span>, S::VERASE),
689+
<span class="comment">// Deletes the current line.
690+
</span>(<span class="string">&quot;kill&quot;</span>, S::VKILL),
691+
<span class="comment">// Signals the end of input.
692+
</span>(<span class="string">&quot;eof&quot;</span>, S::VEOF),
693+
<span class="comment">// Signals the end of line.
694+
</span>(<span class="string">&quot;eol&quot;</span>, S::VEOL),
695+
<span class="comment">// Alternate end-of-line character.
696+
</span>(<span class="string">&quot;eol2&quot;</span>, S::VEOL2),
697+
<span class="comment">// Switch character (only on Linux).
698+
</span><span class="attr">#[cfg(target_os = <span class="string">&quot;linux&quot;</span>)]
699+
</span>(<span class="string">&quot;swtch&quot;</span>, S::VSWTC),
700+
<span class="comment">// Starts output after it has been stopped.
701+
</span>(<span class="string">&quot;start&quot;</span>, S::VSTART),
702+
<span class="comment">// Stops output.
703+
</span>(<span class="string">&quot;stop&quot;</span>, S::VSTOP),
704+
<span class="comment">// Sends a suspend signal (SIGTSTP).
705+
</span>(<span class="string">&quot;susp&quot;</span>, S::VSUSP),
706+
<span class="comment">// Reprints the current line.
707+
</span>(<span class="string">&quot;rprnt&quot;</span>, S::VREPRINT),
708+
<span class="comment">// Deletes the last word typed.
709+
</span>(<span class="string">&quot;werase&quot;</span>, S::VWERASE),
710+
<span class="comment">// Enters literal mode (next character is taken literally).
711+
</span>(<span class="string">&quot;lnext&quot;</span>, S::VLNEXT),
712+
<span class="comment">// Discards the current line.
713+
</span>(<span class="string">&quot;discard&quot;</span>, S::VDISCARD),
714+
];
631715
</code></pre></div></section></main></body></html>

dev/src/uu_stty/stty.rs.html

+97-3
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,67 @@
464464
<a href="#464" id="464">464</a>
465465
<a href="#465" id="465">465</a>
466466
<a href="#466" id="466">466</a>
467+
<a href="#467" id="467">467</a>
468+
<a href="#468" id="468">468</a>
469+
<a href="#469" id="469">469</a>
470+
<a href="#470" id="470">470</a>
471+
<a href="#471" id="471">471</a>
472+
<a href="#472" id="472">472</a>
473+
<a href="#473" id="473">473</a>
474+
<a href="#474" id="474">474</a>
475+
<a href="#475" id="475">475</a>
476+
<a href="#476" id="476">476</a>
477+
<a href="#477" id="477">477</a>
478+
<a href="#478" id="478">478</a>
479+
<a href="#479" id="479">479</a>
480+
<a href="#480" id="480">480</a>
481+
<a href="#481" id="481">481</a>
482+
<a href="#482" id="482">482</a>
483+
<a href="#483" id="483">483</a>
484+
<a href="#484" id="484">484</a>
485+
<a href="#485" id="485">485</a>
486+
<a href="#486" id="486">486</a>
487+
<a href="#487" id="487">487</a>
488+
<a href="#488" id="488">488</a>
489+
<a href="#489" id="489">489</a>
490+
<a href="#490" id="490">490</a>
491+
<a href="#491" id="491">491</a>
492+
<a href="#492" id="492">492</a>
493+
<a href="#493" id="493">493</a>
494+
<a href="#494" id="494">494</a>
495+
<a href="#495" id="495">495</a>
496+
<a href="#496" id="496">496</a>
497+
<a href="#497" id="497">497</a>
498+
<a href="#498" id="498">498</a>
499+
<a href="#499" id="499">499</a>
500+
<a href="#500" id="500">500</a>
501+
<a href="#501" id="501">501</a>
502+
<a href="#502" id="502">502</a>
503+
<a href="#503" id="503">503</a>
504+
<a href="#504" id="504">504</a>
505+
<a href="#505" id="505">505</a>
506+
<a href="#506" id="506">506</a>
507+
<a href="#507" id="507">507</a>
508+
<a href="#508" id="508">508</a>
509+
<a href="#509" id="509">509</a>
510+
<a href="#510" id="510">510</a>
511+
<a href="#511" id="511">511</a>
512+
<a href="#512" id="512">512</a>
513+
<a href="#513" id="513">513</a>
467514
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
468515
// *
469516
// * For the full copyright and license information, please view the LICENSE file
470517
// * that was distributed with this source code.
471518

472-
// spell-checker:ignore clocal tcgetattr tcsetattr tcsanow tiocgwinsz tiocswinsz cfgetospeed cfsetospeed ushort
519+
// spell-checker:ignore clocal erange tcgetattr tcsetattr tcsanow tiocgwinsz tiocswinsz cfgetospeed cfsetospeed ushort vmin vtime
473520

474521
</span><span class="kw">mod </span>flags;
475522

476523
<span class="kw">use </span>clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
477524
<span class="kw">use </span>nix::libc::{c_ushort, O_NONBLOCK, TIOCGWINSZ, TIOCSWINSZ};
478525
<span class="kw">use </span>nix::sys::termios::{
479526
cfgetospeed, cfsetospeed, tcgetattr, tcsetattr, ControlFlags, InputFlags, LocalFlags,
480-
OutputFlags, Termios,
527+
OutputFlags, SpecialCharacterIndices, Termios,
481528
};
482529
<span class="kw">use </span>nix::{ioctl_read_bad, ioctl_write_ptr_bad};
483530
<span class="kw">use </span>std::io::{<span class="self">self</span>, stdout};
@@ -496,7 +543,7 @@
496543
target_os = <span class="string">&quot;openbsd&quot;
497544
</span>)))]
498545
</span><span class="kw">use </span>flags::BAUD_RATES;
499-
<span class="kw">use </span>flags::{CONTROL_FLAGS, INPUT_FLAGS, LOCAL_FLAGS, OUTPUT_FLAGS};
546+
<span class="kw">use </span>flags::{CONTROL_CHARS, CONTROL_FLAGS, INPUT_FLAGS, LOCAL_FLAGS, OUTPUT_FLAGS};
500547

501548
<span class="kw">const </span>USAGE: <span class="kw-2">&amp;</span>str = <span class="macro">help_usage!</span>(<span class="string">&quot;stty.md&quot;</span>);
502549
<span class="kw">const </span>SUMMARY: <span class="kw-2">&amp;</span>str = <span class="macro">help_about!</span>(<span class="string">&quot;stty.md&quot;</span>);
@@ -711,6 +758,52 @@
711758
<span class="prelude-val">Ok</span>(())
712759
}
713760

761+
<span class="kw">fn </span>control_char_to_string(cc: nix::libc::cc_t) -&gt; nix::Result&lt;String&gt; {
762+
<span class="kw">if </span>cc == <span class="number">0 </span>{
763+
<span class="kw">return </span><span class="prelude-val">Ok</span>(<span class="string">&quot;&lt;undef&gt;&quot;</span>.to_string());
764+
}
765+
766+
<span class="kw">let </span>(meta_prefix, code) = <span class="kw">if </span>cc &gt;= <span class="number">0x80 </span>{
767+
(<span class="string">&quot;M-&quot;</span>, cc - <span class="number">0x80</span>)
768+
} <span class="kw">else </span>{
769+
(<span class="string">&quot;&quot;</span>, cc)
770+
};
771+
772+
<span class="comment">// Determine the &#39;^&#39;-prefix if applicable and character based on the code
773+
</span><span class="kw">let </span>(ctrl_prefix, character) = <span class="kw">match </span>code {
774+
<span class="comment">// Control characters in ASCII range
775+
</span><span class="number">0</span>..=<span class="number">0x1f </span>=&gt; <span class="prelude-val">Ok</span>((<span class="string">&quot;^&quot;</span>, (<span class="string">b&#39;@&#39; </span>+ code) <span class="kw">as </span>char)),
776+
<span class="comment">// Printable ASCII characters
777+
</span><span class="number">0x20</span>..=<span class="number">0x7e </span>=&gt; <span class="prelude-val">Ok</span>((<span class="string">&quot;&quot;</span>, code <span class="kw">as </span>char)),
778+
<span class="comment">// DEL character
779+
</span><span class="number">0x7f </span>=&gt; <span class="prelude-val">Ok</span>((<span class="string">&quot;^&quot;</span>, <span class="string">&#39;?&#39;</span>)),
780+
<span class="comment">// Out of range (above 8 bits)
781+
</span><span class="kw">_ </span>=&gt; <span class="prelude-val">Err</span>(nix::errno::Errno::ERANGE),
782+
}<span class="question-mark">?</span>;
783+
784+
<span class="prelude-val">Ok</span>(<span class="macro">format!</span>(<span class="string">&quot;{meta_prefix}{ctrl_prefix}{character}&quot;</span>))
785+
}
786+
787+
<span class="kw">fn </span>print_control_chars(termios: <span class="kw-2">&amp;</span>Termios, opts: <span class="kw-2">&amp;</span>Options) -&gt; nix::Result&lt;()&gt; {
788+
<span class="kw">if </span>!opts.all {
789+
<span class="comment">// TODO: this branch should print values that differ from defaults
790+
</span><span class="kw">return </span><span class="prelude-val">Ok</span>(());
791+
}
792+
793+
<span class="kw">for </span>(text, cc_index) <span class="kw">in </span>CONTROL_CHARS {
794+
<span class="macro">print!</span>(
795+
<span class="string">&quot;{text} = {}; &quot;</span>,
796+
control_char_to_string(termios.control_chars[<span class="kw-2">*</span>cc_index <span class="kw">as </span>usize])<span class="question-mark">?
797+
</span>);
798+
}
799+
<span class="macro">println!</span>(
800+
<span class="string">&quot;min = {}; time = {};&quot;</span>,
801+
termios.control_chars[SpecialCharacterIndices::VMIN <span class="kw">as </span>usize],
802+
termios.control_chars[SpecialCharacterIndices::VTIME <span class="kw">as </span>usize]
803+
);
804+
<span class="prelude-val">Ok</span>(())
805+
}
806+
714807
<span class="kw">fn </span>print_in_save_format(termios: <span class="kw-2">&amp;</span>Termios) {
715808
<span class="macro">print!</span>(
716809
<span class="string">&quot;{:x}:{:x}:{:x}:{:x}&quot;</span>,
@@ -730,6 +823,7 @@
730823
print_in_save_format(termios);
731824
} <span class="kw">else </span>{
732825
print_terminal_size(termios, opts)<span class="question-mark">?</span>;
826+
print_control_chars(termios, opts)<span class="question-mark">?</span>;
733827
print_flags(termios, opts, CONTROL_FLAGS);
734828
print_flags(termios, opts, INPUT_FLAGS);
735829
print_flags(termios, opts, OUTPUT_FLAGS);

0 commit comments

Comments
 (0)