Commit Graph

12732 Commits

Author SHA1 Message Date
David Korth
6056d61f2c NEWS.md: Mention xattr compression algorithms.
Some checks failed
Codecov / run (push) Has been cancelled
2025-05-03 09:44:05 -04:00
David Korth
21cc92b9c6 [librpfile] XAttrReader_p.hpp: Use bitflags instead of bools for all the "has*" variables.
std::bitset<> would also work, but the minimum size of std::bitset<> is
`unsigned long`, so it'd take up 8 bytes.
2025-05-02 23:19:58 -04:00
David Korth
594f379fe3 [librpfile] XAttrReader::hasXfsAttributes(): Fix typo; should return d->hasXfsAttributes, not d->hasExt2Attributes.
Not sure if this caused any weird issues...
2025-05-02 23:12:30 -04:00
David Korth
4c944a2add [gtk] Ext2AttrView: Fix alignment of lblCompression on GTK4.
Needed to enable hexpand and set xalign.

Not sure if this is needed or supported on GTK2 or GTK3, but using
gtk_box_pack_end() seems to work on the older versions anyway.
2025-05-02 21:38:52 -04:00
David Korth
88b9552cca [gtk] Ext2AttrView: Display the compression algorithm, if available.
XAttrView: Set the compression algorithm in Ext2AttrView.

We're using Ext2AttrView because most Linux file systems that support
compression also support Ext2-style attributes.
2025-05-02 21:34:37 -04:00
David Korth
6a425154a2 [kde] Ext2AttrViewPrivate::updateZAlgorithmLabel(): Remove a line of debugging code. 2025-05-02 21:22:44 -04:00
David Korth
dd75ff80ca [kde] Ext2AttrView: Revert the updateDisplay() change. [back to updateFlagsDisplay()]
This function is *only* used for flags. Not the compression algorithm.
2025-05-02 21:22:04 -04:00
David Korth
c9588a89f7 [gtk] Rename Ext2AttrView.c to Ext2AttrView.cpp.
XAttrReader::ZAlgorithm needs C++.
2025-05-02 21:18:10 -04:00
David Korth
147f9c745d [librpfile] XAttrReader: Rename the "compressionAlgorithm" stuff to "zAlgorithm".
[kde,win32] Update for this change.
2025-05-02 21:10:41 -04:00
David Korth
bca1c48b59 [librpfile] XAttrReader_posix.cpp: Remove some compression algorithm debugging code. 2025-05-02 21:06:46 -04:00
David Korth
ce01475b3d [kde] Ext2AttrView: Add a way to display the compression algorithm.
Named "zAlgorithm"; will rename the XAttrReader functions next.

XAttrView: Set the compression algorithm in Ext2AttrView.

We're using Ext2AttrView because most Linux file systems that support
compression also support Ext2-style attributes.
2025-05-02 21:04:13 -04:00
David Korth
2982457dcc [librpfile] XAttrReader_posix.cpp: Get the compression algorithm on btrfs file systems.
This is stored in the "btrfs.compression" extended attribute.

TODO: Add a wrapper function for reading xattrs.
2025-05-02 21:03:40 -04:00
David Korth
1e094fdb8e [gtk] _RpDragImageCxx ctor: Initialize pngBytes to nullptr.
When testing non-RomData files with `rp-stub -R`, I got random crashes.
gdb traced it back to an invalid g_bytes_unref() due to pngBytes not
being initialized properly.

This only affects the GTK4 version.

This fixes a regression from commit bc32b0c3a2.
([gtk] DragImage: Implement GTK4 drag & drop.)

Affects: v2.4 - v2.5
2025-05-02 21:02:59 -04:00
David Korth
1875c9da7e [win32] rp-*.rc: Update IDD_XATTRVIEW in the other languages.
rp-ru_RU.rc: There's now three rows in MS-DOS Attributes.
2025-05-02 20:19:56 -04:00
David Korth
b080caa4bf [win32] rp-en_US.rc: Minor adjustment to the compression algorithm dropdown. 2025-05-02 20:19:37 -04:00
David Korth
9f03ee8d45 [librpfile] XAttrReader: Initial "compression algorithm" function.
If supported, this will get the compression algorithm in use for
the specified file.

Currently, this is only implemented on Windows for both the read
functionality and the display functionality.

Regular NTFS compression uses LZNT1 and is indicated by the presence
of FILE_ATTRIBUTE_COMPRESSED.

Newer compression formats were added in Windows 10:
- XPRESS4K
- LZX
- XPRESS8K
- XPRESS16K

These do *not* set FILE_ATTRIBUTE_COMPRESSED, but for our purposes,
if one of these is set, the "Compressed" box will be checked.

A dropdown is shown that lists the current compression algorithm,
and all other algorithms. This might be changed to just a label
display later, unless I actually add the ability to change it later...
2025-05-02 19:48:44 -04:00
David Korth
d4b1693c49 [librpfile] XAttrReader: Un-indent the public and private class declarations. 2025-05-02 19:45:03 -04:00
David Korth
6f9f6b9cff [librpfile] FileSystem_win32.cpp, filesize_int(): Check for INVALID_HANDLE_VALUE. 2025-05-02 19:32:13 -04:00
David Korth
e9dcd3f131 [rpcli] vt.cpp, win32_console_print_ansi_color(): Get the console handle from ci_stdout.
Some checks failed
Codecov / run (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
2025-05-01 22:45:43 -04:00
David Korth
917f0a497a [rpcli] vt.cpp: Skip "CSI 38 m" and "CSI 48 m".
These are used for truecolor and 256-color formatting, which aren't
supported by the old Windows console. Skip the extra parameters so
they don't cause problems:

- truecolor (2): skip 3 extra parameters
- 256-color (5): skip 1 extra parameter

This required switching from a range-based `for` loop to a regular
index-based `for` loop, since we can't adjust the counter in a
range-based `for` loop.
2025-05-01 22:33:22 -04:00
David Korth
6e80ad584a [rpcli] vt.cpp: Empty parameters (e.g. ";;") are handled as 0.
Initialize num to 0, and reset it to 0 instead of -1.

Remove the explicit params.empty() check, since it will always have at
least one parameter. ("ESC m" will nd up having a single 0 parameter.)
2025-05-01 22:19:45 -04:00
David Korth
836985e6ed [rpcli] vt.cpp: Don't bother checking for 0x9C as an equivalent to "ST".
The ANSI standard says C1 control codes are equivalent, but UTF-8 makes
these take up two bytes, and nothing actually uses them nowadays.
2025-05-01 22:08:10 -04:00
David Korth
2386a99cf3 [rpcli] rpcli.cpp: Add an (undocumented) option to force-enable ANSI color: -C
Tested on Windows 10 and it seems to work for both console output and
redirected file output. Need to test on Linux, Windows XP, and Windows 7.
2025-05-01 22:03:57 -04:00
David Korth
ff63ed7ec9 [rpcli] vt.cpp: Add custom non-localized vt_isdigit() and vt_isalpha() functions.
isdigit() is defined as non-localized in C++, but isalpha() is not.

For consistency, define both here. This ensures that *only* the specified
characters are handled as digit or command characters, whereas the
localized versions might accept some other characters.

It's also slightly faster, since it doesn't have to do any localization
checks. Both gcc and MSVC compile vt_isdigit() to a subtract-and-compare.
gcc compiles vt_isalpha() to an AND, subtract, and compare; MSVC ends up
generating a few subtract-and-compares. (clang has the same behavior as
gcc in this case, though the generated code is slightly different.)
2025-05-01 20:26:12 -04:00
David Korth
6213569763 [rpcli] vt.cpp: Simplify "CSI n X" processing by parsing parameters first, *then* applying them.
This will allow us to implement other "CSI" escape sequences later,
if needed. It also simplifies parsing in general, since, among other
things, we won't start to apply attributes until we know that the
"CSI" command in question is "m" (SGR, Select Graphic Rendition).
2025-05-01 20:16:49 -04:00
David Korth
2566f1302a [librpbase] TextOut_text.cpp, htmlLinkToOsc8(): Make OSC 8 the outer formatting.
Needed for Windows Terminal, and possibly others.
2025-05-01 20:00:36 -04:00
David Korth
d258332227 [librpbase] TextOut_text.cpp: extURL processing: OSC 8 needs to be *outside* of formatting in order to get Windows Terminal to recognize it.
Also, combine the separate sequences into larger strings as a minor
optimization.
2025-05-01 19:58:35 -04:00
David Korth
20b994cc99 [rpcli] vt.cpp, win32_console_print_ansi_color(): Don't apply attributes if the "CSI n" sequence ends with something other than "m".
Some checks failed
Codecov / run (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
We're not supporting other sequences right now, e.g. "CSI n A" for
Cursor Up, but those would otherwise have been applied as attributes,
even though they don't end with "m".

TODO: If we do implement other "CSI n" sequences, we'll need to search
for the terminator before parsing the attributes.
2025-04-29 23:15:09 -04:00
David Korth
59cb37c893 [librpbase] TextOut_text.cpp: Colorize and use "OSC 8" for links in STRF_CREDITS fields.
StringField: New function htmlLinkToOsc8() to convert an HTML link
to OSC 8. The link must be in the following format:

<a href="https://blahblahblah">description</a>

STRF_CREDITS fields are generated by the RomData subclass and not taken
from the ROM file, so this should be consistent. Currently, only one
RomData subclass actually uses STRF_CREDITS: Amiibo

SafeString: Change `bool quotes` to `SafeStringFlags flags`. This contains
two flags: SSF_QUOTES and SSF_NO_ESCAPE. SSF_NO_ESCAPE is used for the
STRF_CREDITS field if using htmlLinkToOsc8(). Again, these fields should
not have weird control codes, since they're generated by the RomData
subclass, not taken from the ROM file.

Konsole seems to recognize "amiibo.life" as a link with the OSC 8 markup,
but not without it, so it seems it *is* working.

NOTE: The HTML link is left as-is if not converting to ANSI escapes.
Maybe it should be processed... (The RomHeaderTest results for Amiibo
would need to be updated in that case.)
2025-04-29 21:10:50 -04:00
David Korth
3a318c5924 [librpbase] TextOut_text.cpp: Use "OSC 8" to indicate hyperlinks.
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
Not all terminal emulators support it. KDE Konsole is listed as
supported, but it doesn't seem to be working here... Need to test
it on other supported terminal emulators.

At the very least, it doesn't cause anything to look *different*
if it's enabled and the terminal emulator doesn't support it.

[rpcli] vt.cpp: Ignore "OSC" sequences, since we can't do hyperlinks
with the older Windows console.
2025-04-29 19:08:17 -04:00
David Korth
94c69214e7 [librpbase] TextOut_text.cpp: Colorize and underline external image hyperlinks.
NOTE: Underlining doesn't work on older Windows. (Definitely not WinXP or
Win7; possibly not Win10 prior to 1607.)
2025-04-29 18:49:14 -04:00
David Korth
bf61261b85 [rpcli] vt.cpp: Improve bold/bright tracking.
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
FIXME: Set bold and/or bright if wAttributesOrig has FOREGROUND_INTENSITY?
2025-04-28 23:24:30 -04:00
David Korth
b4a81e5410 [rpcli] vt.cpp: Add bright foreground and background color attributes.
Bright foreground: 90-97
Bright background: 100-107

Note that these simply set the intensity flag and don't keep track of
whether or not "bright" was set, so setting a "regular" color won't
automatically remove the brightness.
2025-04-28 23:17:45 -04:00
David Korth
1a23dc8464 [rpcli] vt.cpp: Add "not underline" (24) to the ANSI escape sequence parser. 2025-04-28 23:13:56 -04:00
David Korth
365a7d5302 [rpcli] verifykeys.cpp: Colorize output.
Similar color scheme as rpcli.cpp:
- Status messages: Cyan
- Internal warnings: Yellow
- Valid keys: Green (for the "OK" message)
- Invalid keys: Red (for the error message)

The key names are not colorized.
2025-04-28 18:54:42 -04:00
David Korth
fb032f03ea NEWS.md: Mention the TERM check. 2025-04-28 18:49:26 -04:00
David Korth
16ad403a81 [rpcli] vt.cpp: Simplify init_posix_ConsoleInfo_t() a bit. 2025-04-28 18:45:40 -04:00
David Korth
397afc7166 [rpcli] vt.cpp: Check TERM once instead of twice.
TERM doesn't change for different file handles, so there's no need to
check it once for stdout and once for stderr.

Internal variable is_color_TERM is set by check_TERM_variable().
It's copied into ConsoleInfo_t for use elsewhere.
2025-04-28 18:44:08 -04:00
David Korth
a7c119805f [rpcli] Disable ANSI color on non-Windows systems if TERM isn't set to a valid color terminal.
Supported terminals match this regex:

(?i)^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux

rpcli.cpp: On Non-Windows systems, don't set OF_Text_UseAnsiColor if
the console doesn't support ANSI color.

vt.cpp: On Non-Windows systems, do nothing in the various Console*()
color functions if the console doesn't support ANSI color.
2025-04-28 18:40:12 -04:00
David Korth
191cbab172 [cmake] gcc.cmake: Add some more clang libc++ hardening options.
These options are now only applied if compiling with clang.

While it's possible to use libc++ with gcc, it requires a lot of manual
changes, and basicaly no one does it. (libstdc++ with clang is commonly
done on desktop Linux systems, though.)

Don't -D_LIBCPP_ENABLE_ASSERTIONS on clang-17 or later. It's deprecated,
and may result in a compile error. (...though on Android/Termux with
clang-20.1.3, it didn't...)
2025-04-28 18:22:21 -04:00
David Korth
bd5b649bf3 [libromdata] CMakeLists.txt: Bump the SOVERSION to 6.1.
It's ABI-compatible with 6.0 (using only .so.6, not .so.6.1), but there
have been changes since the previous release.
2025-04-28 18:21:02 -04:00
David Korth
3e853a59da [cmake] Don't enable -Werror or /WX by default; add a CMake option -DENABLE_WERROR.
Newer compilers usually add more warnings, so having -Werror by default
will most likely result in a compile error when new compiler versions
are released.

MSVC: Remove "-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING". This is no
longer relevant, since we don't support anything older than MSVC 2015.
2025-04-28 18:19:53 -04:00
David Korth
1dc3609bc7 [rpcli] rpcli.cpp: Colorize output in ExtractImages().
NOTE: Using Yellow for cases where an animated icon is requested but
libpng doesn't support APNG.

Add "is" to the "APNG is not supported" line.
2025-04-28 18:19:02 -04:00
David Korth
b347c4fad6 [rpcli] vt.cpp: Handle len < 0 in the Win32 UTF-16 case.
Previously, when we used utf8_to_utf16(), this was automatically handled
by utf8_to_utf16(). Since we're not using that anymore, we have to call
strlen() ourselves. Otherwise, MultiByteToWideChar() will add the extra
NULL byte to the character count, resulting in an extra "space" being
written to the console. This causes the "-- Extracting..." text to be
offset by one space when extracting an internal image.

This fixes a regression from commit faeca807bd.
([rpcli] rpcli.cpp: Add color to the libgnuintl-8.dll and romdata-6.dll error messages.)
2025-04-28 18:16:52 -04:00
David Korth
7d379f826d [cmake] gcc.cmake: Fix DT_RELR enablement.
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
It seems this was broken since it was initially implemented in v2.0
in commit d732fbc010
([cmake] platform/gcc.cmake: Initial support for detecting DT_RELR.)
because TMP_HAVE_DT_RELR was unset too early.
2025-04-28 01:03:31 -04:00
David Korth
3b8d47fa0b [rpcli] rpcli.cpp: Clear attributes before printing the newline.
This does mean we can't use ConsolePrint()'s newline parameter, so we'll
have to call ConsolePrintNewline() separately.

TextOut_text.cpp effectively does this already for "warning" fields.
2025-04-27 19:33:27 -04:00
David Korth
91d51920df [rpcli] vt.cpp: Use "\033[0m" instead of "\033[m".
Both are equivalent, but "0" might be more compatible.
2025-04-27 19:24:28 -04:00
David Korth
21e692e9cf NEWS.md: Mention rpcli colorizing more stuff. 2025-04-27 19:21:53 -04:00
David Korth
faeca807bd [rpcli] rpcli.cpp: Add color to the libgnuintl-8.dll and romdata-6.dll error messages.
NOTE: ConsolePrint() currently uses utf8_to_utf16() if printing to a
Windows console and ANSI isn't supported. This function is located
in libromdata (librptext), so we can't use it if romdata-6.dll is
missing. Use MultiByteToWideChar() directly instead. This might also
slightly improve performance, since an std::u16string is no longer
needed.

GDI+ init error: Localize the string. This can be localized because
libgnuintl-8.dll was already verified to be present at this point.
2025-04-27 19:18:20 -04:00
David Korth
7726fc6dfd [libi18n] i18n.h: Remove #include <tchar.h> and don't use _T() for LIBGNUINTL_DLL.
[rpcli] rpcli.cpp: Use _T(LIBGNUINTL_DLL) here.

[win32] NetworkStatus.c, ConfigDialog.cpp: #include <tchar.h>
2025-04-27 19:08:50 -04:00