← Architecture · Back to README · Testing →
Development guide for Far-NetBox. Target audience: AI assistants and human contributors working on the C++17/MSVC/CMake codebase.
| Element | Convention | Example |
|---|---|---|
| Classes | T + PascalCase |
TSessionData, TSecureShell |
| Methods | PascalCase | GetSessionData(), Connect() |
| Member variables | F + PascalCase |
FSessionData, FConfig |
| Local variables | camelCase | sessionData, configValue |
| Constants | UPPER_CASE | MAX_RETRY_COUNT |
- Brace style: Allman (opening brace on new line)
- Indentation: 2 spaces (no tabs)
- Line endings: CRLF (Windows)
- Encoding: UTF-8 without BOM
- Pointer/reference: Middle alignment (
int * ptr) - Max line length: 120 characters
- No trailing whitespace
- Include guards:
#pragma once - Include order: System headers → Project headers → Local headers
- Extensions:
.h/.hppfor headers,.cppfor sources
- Prefer RAII and smart pointers (
std::unique_ptr) - Avoid raw
new/delete - Check for null before dereferencing
- Use exceptions for error conditions, not return codes
- Log with
FTerminal->LogEvent()for debug output - Use
DebugAssert()for invariants (fires in debug builds)
The Sysutils namespace in src/base/Sysutils.hpp provides common string operations for dialog labels and file paths:
| Function | Purpose |
|---|---|
RightCutToLength(Str, MaxLength, Ellipsis) |
Truncate from the right; keeps left portion, appends Unicode ellipsis \u2026 |
CutToLength(Str, MaxLength, Ellipsis) |
Truncate from the right with parenthesized suffix preservation (e.g. "TLS client certificate (PEM)" -> "TLS client cert… (PEM)") |
Both functions use 1-based indexing following the VCL/BCB6 convention. When truncating dialog label text, call ::StripHotkey() first to remove Far Manager & hotkey markers -- they count toward .Length() but are invisible on screen, causing incorrect truncation width.
All Far Manager API calls must execute on the main thread. Worker threads use event-driven waits (WaitForSingleObject) instead of busy-waiting (Sleep loops).
See .ai-factory/rules/threading.md for the full threading convention rules.
MsgIDs.h defines an ordered enum of message identifiers. Every .lng
file (English, Russian, French, Polish, Spanish) must contain the same
number of quoted strings in the exact same order.
Blank lines and the .Language=… header do not count as strings.
Why it matters: GetMsg(MsgId) indexes directly into the .lng
string table. If a string is inserted at the wrong position, every
subsequent string shifts, and the UI displays the wrong text or
crashes Far Manager at runtime.
Rule: Before adding new strings, run:
python scripts/verify_lng_alignment.pyWhen adding N new NB_* or MSG_* identifiers to MsgIDs.h, you
must insert exactly N new quoted strings at the same zero-based
index into all five .lng files. The script reports the line
number for every enum so you can verify placement.
- Add the new enum constant(s) to
MsgIDs.hat the correct logical position (e.g., afterNB_TRANSFER_REMEMBER_PASSWORD). - Run
python scripts/verify_lng_alignment.pyto see the target line number in each.lngfile. - Insert the translated quoted strings at those line numbers.
- Re-run the script until all counts match and key indices align.
cmd /c build-x64.batrmdir /s /q build-RelWithDebugInfo
cmd /c build-x64.batcmake --build build-RelWithDebugInfo --clean-first -- -j4| Option | Values | Default | Description |
|---|---|---|---|
CMAKE_BUILD_TYPE |
Debug, Release, RelWithDebugInfo | Debug | Build configuration |
PROJECT_PLATFORM |
x86, x64, ARM64 | Auto-detected | Target architecture |
OPT_CREATE_PLUGIN_DIR |
ON, OFF | OFF | Create plugin directory structure |
OPT_USE_UNITY_BUILD |
ON, OFF | ON (x86 Release) | Faster compilation |
Symbol redefinition errors indicate unity build is the culprit. Disable:
cmake -S . -B build-RelWithDebugInfo -DOPT_USE_UNITY_BUILD=OFF ...After updating OpenSSL from upstream (WinSCP), re-apply the patch:
git -C libs\openssl-3 apply -p3 0001-openssl-apply-NetBox-patches.patch- Main branch:
main(protected) - Branch naming:
feature/description,fix/description,refactor/description - Commit messages: Imperative mood, under 72 chars summary
- Skip CI:
[skip ci]in commit message
- Build with
OPT_CREATE_PLUGIN_DIR=ON - Launch Far Manager from platform directory:
Far3_x64\Far.exe - Press
F11→ Plugins → NetBox - Test the affected functionality
- Check log:
%LOCALAPPDATA%\NetBox\netbox.log
- Skip protocol inheritance — all protocols must inherit from
TCustomFileSystem - Direct third-party changes — modify
libs/only after confirmation - Skip build verification — changes must compile without warnings
- No debug output — use
FTerminal->LogEvent()for tracing - Skip exception handling — network errors must be caught
- Mix layers — plugin code should not call third-party directly
NetBox maintains Windows XP compatibility for the x86 (Win32) platform because the Far Manager ecosystem includes users on legacy Windows systems.
The GitHub Actions release.yml workflow includes a dedicated cl_x86_winxp_release matrix entry that produces XP-compatible binaries:
- Subsystem version: The CMake linker flag is set to
/SUBSYSTEM:WINDOWS,5.01for x86 builds (seecmake/NetBox.cmake) - Toolset: The workflow attempts to use the v141 toolset (
toolset: 14.1) viailammy/msvc-dev-cmd; if unavailable on thewindows-2022runner, it falls back to v143 with a warning - Build isolation: Each matrix job uses a separate build directory (
build-${{ matrix.build }}) to prevent CMake cache conflicts - Binary verification: The CI runs
dumpbin /headersto verify subsystem5.01and checks for API set dependencies
To verify that a locally built x86 binary is XP-compatible:
dumpbin /headers Far3_x86\Plugins\NetBox\NetBox.dll | findstr /i "subsystem"The output must contain 5.01. If it shows 6.00, the binary requires Windows Vista or later.
- v141_xp (the historical XP-targeting toolset) is not available in Visual Studio 2022
- The v143 fallback relies on
vc_crt_fix_impl.cppAPI shims and the manual subsystem version fix - WinXP x64 builds are intentionally out of scope
For the full API shim inventory, build configuration details, and how to add new stubs, see .ai-factory/windows-xp-compatibility.md.
- Testing — Manual regression testing guide
- Architecture — Project structure and patterns
.ai-factory/AGENTS.md— Full AI development guide with deep references