Skip to content

Commit 02f4c33

Browse files
authored
Merge pull request #824 from o-sdn-o/gui-bridge
Make Lua script compilation error messages more clear (add line numbering)
2 parents ff7a0c4 + 97e87ab commit 02f4c33

File tree

12 files changed

+51
-42
lines changed

12 files changed

+51
-42
lines changed

doc/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ In ANSI/VT IO mode, vtm process parses input from multiple standard sources, and
243243
- SIGINT events are forwarded to the process lifetime control channel to perform graceful exit.
244244
- SIGHUP events are forwarded to the process lifetime control channel to perform graceful exit.
245245
- SIGTERM events are forwarded to the process lifetime control channel to perform graceful exit.
246-
- PS/2 Mouse device (Linux VGA Console only)
246+
- PS/2 Mouse device (Linux VGA Console (in-kernel console) only)
247247
- `/dev/input/mice`: Received ImPS/2 mouse protocol events are decoded and forwarded to the mouse event channel.
248248
- `/dev/input/mice.vtm` (used in case of inaccessibility of `/dev/input/mice`)
249249

doc/command-line-options.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Option | Description
2525
`-i`, `--install` | Perform system-wide installation. Allow Desktop Server to run in user context in Session 0 on Windows.<br>Placing Desktop Server in Session 0 allows console applications to run independently of the user's GUI login session. Note: This prevents GUI applications from running from the vtm desktop environment. See "Session 0 Isolation" on the Web for details.<br>Elevated privileges required.
2626
`-u`, `--uninstall` | Perform system-wide deinstallation.<br>Elevated privileges required.
2727
`-0`, `--session0` | Use Session 0 to run Desktop Server in background. For Windows only.
28-
`-a`, `--mouse [mode]` | Set/reset persistent access to mouse devices for all users on Linux platform.<br>Run `sudo vtm --mouse 0` to reset access.<br>Elevated privileges required.
28+
`-a`, `--mouse [mode]` | Set/reset persistent access to mouse devices for all users on Linux platform (excluding Android).<br>Run `sudo vtm --mouse 0` to reset access.<br>Elevated privileges required.
2929
`-q`, `--quiet` | Disable logging.
3030
`-x`, `--script <cmds>` | Specifies script commands to be run by the desktop when ready.
3131
`-c`, `--config <file>` | Specifies a settings file to load or plain xml-data to merge.
@@ -52,17 +52,17 @@ The plain xml-data could be specified in place of `<file>` in `--config <file>`
5252
vtm -c "<config/terminal/scrollback size=1000000/>" -r term
5353
```
5454

55-
#### Linux VGA Console
55+
#### Linux VGA Console (in-kernel console)
56+
57+
In order to use a mouse or touchpad in Linux VGA Console, you must grant the user access to mouse/pointing devices. By default, only privileged users and users of the `input` group have access. To grant all users permanent access to all pointing devices, use the command:
5658

57-
In order to use a mouse or touchpad in Linux VGA Console, you must grant the user access to the mouse device. By default, only privileged users and users of the `input` group have access. To grant temporary access, use the command:
5859
- ```
59-
sudo vtm --SetMouseAccess
60+
sudo vtm --mouse
6061
```
61-
To grant permanent access, you must assign the appropriate access rights to the `/dev/input/eventN` files associated with the mouse devices. The device associations could be found using the following command:
62+
To reset permanent access, use the command:
6263
- ```
63-
cat /proc/bus/input/devices
64+
sudo vtm --mouse 0
6465
```
65-
Note: The `/dev/input/eventN` files are temporary, created by `udev` each time the system starts.
6666

6767
### Desktop Applets
6868

src/netxs/apps.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ namespace netxs::app::shared
600600
->limits({ -1,-1 }, { -1,-1 });
601601
static const auto data = []
602602
{
603-
auto [days, hours, mins, secs, msecs] = datetime::breakdown(datetime::now() - os::process::id.second);
603+
auto [days, hours, mins, secs, msecs, micro] = datetime::breakdown(datetime::now() - os::process::id.second);
604604
auto uptime = (days ? std::to_string(days) + skin::globals().NsInfoUptime_d + " " : ""s)
605605
+ (hours ? std::to_string(hours) + skin::globals().NsInfoUptime_h + " " : ""s)
606606
+ (mins ? std::to_string(mins) + skin::globals().NsInfoUptime_m + " " : ""s)

src/netxs/desktopio/ansivt.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,24 @@ namespace netxs::ansi
887887
}
888888
return *this;
889889
}
890+
auto& numerate_lines(argb liter_fg)
891+
{
892+
auto count = 1;
893+
auto width = 0_sz;
894+
auto total = std::count(text::begin(), text::end(), '\n');
895+
while (total)
896+
{
897+
total /= 10;
898+
width++;
899+
}
900+
auto numerate = [&]
901+
{
902+
return escx{}.pushsgr().fgc(liter_fg).add(utf::adjust(std::to_string(count++), width, ' ', true), ": ").popsgr();
903+
};
904+
*this = numerate().add(*this);
905+
utf::for_each(*this, "\n", [&]{ return "\n" + numerate(); });
906+
return *this;
907+
}
890908
};
891909

892910
template<bool UseSGR = true, bool Initial = true, bool Finalize = true, bool Select_11_only = true>

src/netxs/desktopio/application.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace netxs::app
2222

2323
namespace netxs::app::shared
2424
{
25-
static const auto version = "v2025.10.12";
25+
static const auto version = "v2025.10.13";
2626
static const auto repository = "https://github.com/directvt/vtm";
2727
static const auto usr_config = "~/.config/vtm/settings.xml"s;
2828
static const auto sys_config = "/etc/vtm/settings.xml"s;

src/netxs/desktopio/controls.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ namespace netxs::events
434434
if (error)
435435
{
436436
result = ::lua_tostring(lua, -1);
437-
log("%%%msg%", prompt::lua, ansi::err(result));
437+
log("%%script compilation failed:\n%body%\n%msg%\n", prompt::lua, ansi::hi(ansi::add(script_body).numerate_lines(blacklt)), ansi::err(result));
438438
//::lua_pop(lua, 1); // Pop error message from stack.
439439
}
440440
else if (::lua_gettop(lua))
@@ -519,11 +519,11 @@ namespace netxs::events
519519
else // It is not precompiled yet.
520520
{
521521
::lua_pop(lua, 1); // Pop nil after the ::lua_rawget() call.
522-
auto error = ::luaL_loadbuffer(lua, script_body.data(), script_body.size(), "precompilation");
522+
auto error = ::luaL_loadbuffer(lua, script_body.data(), script_body.size(), "script");
523523
if (error)
524524
{
525525
auto result = ::lua_tostring(lua, -1);
526-
log("%%Precompilation error: %msg%", prompt::lua, ansi::err(result));
526+
log("%%script precompilation failed:\n%body%\n%msg%\n", prompt::lua, ansi::hi(ansi::add(script_body).numerate_lines(blacklt)), ansi::err(result));
527527
::lua_pop(lua, 1); // Pop error message from stack.
528528
}
529529
else

src/netxs/desktopio/events.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "xml.hpp"
99

1010
//todo Workaround for i386 linux targets, https://sourceware.org/bugzilla/show_bug.cgi?id=31775
11-
#if defined(__i386__) && defined(__linux__)
11+
#if defined(__i386__) && defined(__linux__) && !defined(__ANDROID__)
1212
extern long double fmodl(long double a, long double b);
1313
double fmod(double a, double b) { return fmodl(a, b); }
1414
float fmod(float a, float b) { return fmodl(a, b); }
@@ -229,7 +229,10 @@ namespace netxs::events
229229
{
230230
auto& context = script_ptr->context;
231231
auto& [ref_count, script_body] = *(script_ptr->script_body_ptr);
232+
//auto start = datetime::now();
232233
luafx.run(context, script_body, param);
234+
//auto [days, hours, mins, secs, msecs, micro] = datetime::breakdown(datetime::now() - start);
235+
//log("Exec duration: %sec%.%msec%.%micro%", secs, msecs, micro);
233236
}
234237
else if (auto& proc = get_inst<Arg>())
235238
{

src/netxs/desktopio/quartz.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ namespace netxs::datetime
5050
auto breakdown(span t)
5151
{
5252
auto days = datetime::round<ui32, std::chrono:: days>(t);
53-
auto hours = datetime::round<ui32, std::chrono:: hours>(t -= std::chrono:: days{ days });
54-
auto minutes = datetime::round<ui32, std::chrono:: minutes>(t -= std::chrono:: hours{ hours });
55-
auto seconds = datetime::round<ui32, std::chrono:: seconds>(t -= std::chrono::minutes{ minutes });
56-
auto milliseconds = datetime::round<ui32, std::chrono::milliseconds>(t -= std::chrono::seconds{ seconds });
57-
return std::tuple{ days, hours, minutes, seconds, milliseconds };
53+
auto hours = datetime::round<ui32, std::chrono:: hours>(t -= std::chrono:: days{ days });
54+
auto minutes = datetime::round<ui32, std::chrono:: minutes>(t -= std::chrono:: hours{ hours });
55+
auto seconds = datetime::round<ui32, std::chrono:: seconds>(t -= std::chrono:: minutes{ minutes });
56+
auto milliseconds = datetime::round<ui32, std::chrono::milliseconds>(t -= std::chrono:: seconds{ seconds });
57+
auto microseconds = datetime::round<ui32, std::chrono::microseconds>(t -= std::chrono::milliseconds{ milliseconds });
58+
return std::tuple{ days, hours, minutes, seconds, milliseconds, microseconds };
5859
}
5960
auto breakdown(time t)
6061
{

src/netxs/desktopio/system.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
#include <linux/kd.h> // ::console_ioctl()
6060
#else
6161
#include <sys/kd.h> // ::console_ioctl()
62+
#include <linux/input.h>// mouse button codes: BTN_LEFT ...
6263
#endif
6364
#include <linux/keyboard.h> // ::keyb_ioctl()
64-
#include <linux/input.h> // mouse button codes: BTN_LEFT ...
6565
#endif
6666

6767
#if defined(__APPLE__)
@@ -4770,7 +4770,7 @@ namespace netxs::os
47704770
}
47714771
});
47724772
}
4773-
#if defined(__linux__)
4773+
#if defined(__linux__) && !defined(__ANDROID__)
47744774
}
47754775
}
47764776
#include "lixx.hpp" // libinput++
@@ -5262,7 +5262,7 @@ namespace netxs::os
52625262
#endif
52635263
return state;
52645264
};
5265-
#if defined(__linux__)
5265+
#if defined(__linux__) && !defined(__ANDROID__)
52665266
if (dtvt::vtmode & ui::console::mouse) // Trying to get direct mouse access.
52675267
{
52685268
if (auto li = lixx::initialize())
@@ -6016,7 +6016,7 @@ namespace netxs::os
60166016
timecod = time{},
60176017
dev_map = std::unordered_map<arch, si32>{}]() mutable
60186018
{
6019-
#if defined(__linux__)
6019+
#if defined(__linux__) && !defined(__ANDROID__)
60206020
using namespace netxs::lixx;
60216021
lixx::li->libinput_dispatch();
60226022
while (true)
@@ -6163,7 +6163,7 @@ namespace netxs::os
61636163
micefd, m_proc,
61646164
alarm, f_proc);
61656165
}
6166-
#if defined(__linux__)
6166+
#if defined(__linux__) && !defined(__ANDROID__)
61676167
lixx::uninitialize();
61686168
#endif
61696169

src/netxs/desktopio/terminal.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ namespace netxs::ui
13881388
auto nothing = match.each([](auto& c){ return !c.isspc(); });
13891389
if (nothing) match = {};
13901390
}
1391-
++alive;
1391+
alive = datetime::uniqueid();
13921392
}
13931393
// bufferbase: Ping selection state if is available.
13941394
void selection_review()

0 commit comments

Comments
 (0)