3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00
Commit Graph

67 Commits

Author SHA1 Message Date
James Prestwood
dc6575130e client: fix missing character for line breaks without spaces
In nearly all cases the auto-line breaks can be on spaces in the
string. The only exception (so far) is DPP which displays a very
long URI without any spaces. When this is displayed a single
character was lost on each break. This was due to the current line
being NULL terminated prior to the next line string being returned.

To handle both cases the next line is copied prior to terminating
the current line. The offsets were modified slightly so the line
will be broken *after* the space, not on the space. This leaves
the space at the end of the current line which is invisible to the
user but allows the no-space case to also work without loss of
the last character (since that last character is where the space
normally would be).
2022-10-12 13:55:57 -05:00
James Prestwood
9d042ca321 client: fix not accounting for color escapes after line break
Each color escape is tracked and the new_width is adjusted
accordingly. But if the color escape comes after a space which breaks
the line, the adjusted width ends up being too long since that escape
sequence isn't appearing on the current line. This causes the next
column to be shifted over.
2022-10-12 13:55:47 -05:00
James Prestwood
ea82616b6b client: add extra parameter for new width when printing rows
The old 'max' parameter was being used both as an input and output
parameter which was confusing. Instead have next_line take the
column width as input, and output a new width which includes any
color escapes and wide characters.
2022-10-12 13:52:40 -05:00
James Prestwood
5010ca2c99 client: validate utf-8 before displaying row
In theory any input to this function should have valid utf-8 but
just in case the strings should be validated. This removes the
need to check the return of l_utf8_get_codepoint which is useful
since there is no graceful failure path at this point.
2022-10-12 13:52:10 -05:00
Pinghao Wu
d82869c346 client: handle wide chars for table rows
Find out printing width of wide chars via wcwidth().
2022-10-12 11:26:01 -05:00
James Prestwood
f9b7e32c2d client: better support utf-8 for table rows
The utf-8 bytes were being counted as normal ascii so the
width maximum was not being increased to include
non-printable bytes like it is for color escape sequences.
This lead to the row not printing enough characters which
effected the text further down the line.

Fix this by increasing 'max' when non-codepoint utf-8
characters are found.
2022-10-07 22:24:03 -05:00
James Prestwood
0b68601c10 client: make COLOR_* macros take a string input
The existing color code escape sequences required the user to set the
color, write the string, then unset with COLOR_OFF. Instead the macros
can be made to take the string itself and automatically terminate the
color with COLOR_OFF. This makes for much more concise strings.
2022-07-07 14:09:03 -05:00
James Prestwood
80051f0124 client: add generic display function for table rows
There was no easy to use API for printing the contents of a table, and
was left up to the caller to handle manually. This adds display_table_row
which makes displaying tables much easier, including automatic support
for line truncation and continuation on the next line.

Lines which are too long will be truncated and displayed on the next
line while also taking into account any colored output. This works with any
number of columns.

This removes the need for the module to play games with encoding newlines
and tabs to make the output look nice.

As a start, this functionality was added to the command display.
2022-07-07 14:08:56 -05:00
James Prestwood
a327e3f4d8 client: remove warning on mkdir return
This fixes up a previous commit which breaks iwctl. The
check was added to satisfy static analysis but it ended
up preventing iwctl from starting. In this case mkdir
can fail (e.g. if the directory already exists) and only
if it fails should the history be read. Otherwise a
successful mkdir return indicates the history folder is
new and there is no reason to try reading it.
2021-02-09 14:49:17 -06:00
James Prestwood
17ba7e415b client: check mkdir return in display_init
Printing a warning is about all that we can do at this
point during initialization.
2021-02-08 14:23:15 -06:00
James Prestwood
3f1cd5a596 display: use l_strlcpy to avoid potential overflow
If 'entry' exceeds the length of 'line' we could overflow. Instead
use l_strlcpy and pass in the remaining amount of data left in
the buffer.
2021-02-08 14:23:04 -06:00
James Prestwood
8539c7aa9e client: remove display_dictionary
This has been replaced by diagnostic_display
2021-01-22 15:02:54 -06:00
James Prestwood
9ac59700d1 client: implement display_dictionary
This takes a Dbus iterator which has been entered into a
dictionary and prints out each key and value. It requires
a mapping which maps keys to types and units. For simple
cases the mapping will consist of a dbus type character
and a units string, e.g. dBm, Kbit/s etc. For more complex
printing which requires processing the value the 'units'
void* cant be set to a function which can be custom written
to handle the value.
2021-01-21 13:48:43 -06:00
Ronan Pigott
0193940e50 client: ignore control sequence length in prompt
Readline uses the characters \001 and \002 to mark the start and end
of zero-length character sequnces in the prompt before prompt
expansion. Without these characters the input point can become offset
from the visual end of the prompt when performing some actions.
2020-12-09 09:40:40 -06:00
Tim Kourt
5d68fbd55f client: Automate display refresh enablement
The display refresh is automatically enabled or disabled depending on
the width of the window. This allows to avoid the incorrect display on
refresh for the small windows.
2020-04-08 21:01:27 -05:00
Tim Kourt
9eeaedf189 client: Rename window change signal for clarity 2020-04-08 21:01:18 -05:00
Tim Kourt
36f962a4f0 client: Rephrase the wait messages 2020-04-08 16:14:29 -05:00
Tim Kourt
61e8a640b1 client: Rewrite workaround for readline
Instead of calling display(""), explicitly use the sequence of
commands to force readline to properly update its internal state
and re-display the prompt.
2020-04-08 16:13:45 -05:00
Marcel Holtmann
d3e00d7f0f client: Use XDG_DATA_HOME for history file if available 2019-12-13 09:33:19 +01:00
Marcel Holtmann
89e476d992 client: Use include path from top source directory 2019-12-13 09:02:42 +01:00
Tim Kourt
f20298dc4a client: Update rl_point to last known position
Keep cursor's position consistent when passphrase is reaching
its maximum by adding characters in the middle of the string

The use case is very rare as not many people will attempt to
modify the masked passphrase from the middle.
2019-10-29 18:17:33 -05:00
Tim Kourt
17ee4196f4 client: Increase passphrase buffer to accommodate for nil byte 2019-10-29 18:17:33 -05:00
Tim Kourt
37e6f6f08b client: Cancel agent prompt with CTRL+D
Previously, CTRL+D used to cause termination of the client. Now, the
command will cancel the agent’s prompts in agent mod. In regular mode
the behavior is unchanged.
2019-10-28 14:57:19 -05:00
Marcel Holtmann
152b56a12a treewide: Move the Intel copyright forward to 2019 2019-10-25 00:43:08 +02:00
Tim Kourt
ea0fc68597 client: Check family name before comparison 2019-10-23 17:59:41 -05:00
Tim Kourt
df32279a31 client: Enable non-interactive mode support for agent prompts 2019-09-02 16:12:37 -05:00
Tim Kourt
ebad9bf9be client: Enhance secret masking
Due to the changed IO behavior, pasting of the secrets
into the agent prompt became impossible. The reimplemented
logic allows to add (paste) an arbitrary number of characters
into a desired position of a secret string up to its max lengths.
The deletion has also been reworked to accommodate the new behavior.
2019-08-27 13:25:14 -05:00
Tim Kourt
44fcb2b1d7 client: Preserve command history in between the instances
This also limits the number of entries in history to 24.
2019-08-27 10:30:01 -05:00
Tim Kourt
09f454b19f client: Refactor error message formating 2019-08-15 15:06:59 -05:00
Tim Kourt
34800bfa63 client: Enable word completion for the SSIDs with spaces
"I--> results in "IWD 1"
2019-07-23 17:20:39 -05:00
Tim Kourt
3d0f1dae12 client: Remove 'quit' message 2019-04-09 00:04:47 -05:00
Jason Phan
25823752b3 client: Fix prompt masking
Entering 23 characters at a prompt resulted in 9 extra characters being
added to the line. At this point, you would only be abel to backspace
until the 9th character.

It seems that claling both rl_replace_line("", 0) and rl_redisplay()
before rl_replace_line(masked_input.mask, 0) causes this to happen. Both
calls are redundant anyways as iwctl functions exactly the same without
them (plus no more bug).
2019-03-21 16:16:59 -05:00
Tim Kourt
a7c28c4977 client: Fix display of the quoted params 2018-11-12 10:37:19 -06:00
Tim Kourt
7df4f2e86b client: Fix display refresh after agent prompt
The line count was one line off after the Agent prompt, thus making
the command output to scroll up on each refresh.
2018-11-12 10:36:58 -06:00
Tim Kourt
67f245a497 client: Fix argv for display refresh 2018-11-09 11:34:43 -06:00
Marcel Holtmann
63bafa7adf client: Fix includes for using with -std=c99 compiler option 2018-11-01 22:19:45 +01:00
Marcel Holtmann
72a64fa7fb build: Adjust to the latest ELL signal API changes 2018-11-01 22:09:19 +01:00
Andrew Zaborowski
558341a689 client: Fix two format strings 2018-11-01 15:04:56 -05:00
Tim Kourt
ce4a272186 client: move static array inits out of display_init() 2018-08-03 14:42:04 -05:00
Andrew Zaborowski
f6aa2c7236 client: Fix comparing current prompt against previous
We'd add the new command propmpt to history if it was different from
what current_history() returned which may not be the last command
executed, so we'd possibly add multiple identical commands to history
and skip some that were new.  Instead compare against
history_get(last index).
Also remove an always-true part of the condition on the next line.
2018-08-01 09:32:00 -05:00
Tim Kourt
e3737fd44e client: fix mem leak after arg parsing 2018-07-30 13:18:35 -05:00
Denis Kenzior
67e590cfeb client: Utilize l_parse_args 2018-07-30 08:59:55 -05:00
Tim Kourt
bb4df24fc5 client: workaround for readline prompt setting issue 2018-05-31 19:40:22 -05:00
Tim Kourt
0716334e61 client: Enable agent to control its prompt 2018-05-04 19:37:38 -05:00
Tim Kourt
394e274f5f client: mask passphrase input 2018-05-03 16:34:26 -05:00
Tim Kourt
2817aeb35d client: disable cmd completion for the agent prompt 2018-05-03 16:00:23 -05:00
Tim Kourt
af14445509 client: add agent prompt to display 2018-05-03 16:00:23 -05:00
Tim Kourt
8071b51168 client: do display quit on exit 2017-06-09 14:08:21 -05:00
Tim Kourt
3bfbe72e33 client: Disable cmd refresh on console resize 2017-06-09 14:08:21 -05:00
Tim Kourt
2fb671e0d4 client: add flashing indicator for the updatable tables 2017-06-09 14:08:21 -05:00