Skip to content

Commit

Permalink
more work on mouseopt
Browse files Browse the repository at this point in the history
Make it parse /OPT[1|0]
Note: notation [1|0] is used for default-enabled options,
[0|1] is used for default-disabled.
  • Loading branch information
stsp committed Mar 29, 2024
1 parent f96ec35 commit c816336
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ There is a `mouseopt` command that controls mouse behavior.
It has the following switches:

- /M - initialize mouse (if /M was not passed to comcom on start)
- /D - disable mouse
- /E - enable mouse previously disabled with /D
- /C - enable external control
- /E[1|0] - enable/disable mouse
- /C[0|1] - enable/disable external control

External control allows to control other programs with mouse.
For example you can execute `mouseopt /c`, then run freecom and
Expand Down
43 changes: 24 additions & 19 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static int shell_permanent;
static int stepping;
static int mouse_en;
static int mouseopt_extctl;
static int mouseopt_disabled;
static int mouseopt_enabled = 1;

#define DEBUG 0

Expand Down Expand Up @@ -3098,7 +3098,7 @@ static void perform_external_cmd(int call, int lh, char *ext_cmd)
_fpreset();
reset_text_attrs();
gppconio_init(); /* video mode could change */
if (mouse_en && !mouseopt_disabled)
if (mouse_en && mouseopt_enabled)
mouse_enable();

sprintf(el, "%d", error_level);
Expand Down Expand Up @@ -3338,35 +3338,40 @@ static void perform_mouseopt(const char *arg)
{
if (arg[0] != '\0')
{
if (stricmp(arg, "/C") == 0)
mouseopt_extctl = 1;
if (stricmp(arg, "/D") == 0)
int opt = 1;
if (isdigit(arg[2]))
opt = arg[2] - '0';

if (strnicmp(arg, "/C", 2) == 0 && mouseopt_extctl != opt)
mouseopt_extctl = opt;
if (strnicmp(arg, "/E", 2) == 0 && mouseopt_enabled != opt)
{
if (mouse_en)
{
mouse_disable();
mouseopt_disabled = 1;
}
}
if (stricmp(arg, "/E") == 0)
{
if (mouseopt_disabled)
{
mouseopt_disabled = 0;
mouse_enable();
if (opt)
{
mouse_enable();
mouseopt_enabled = 1;
}
else
{
mouseopt_enabled = 0;
mouse_disable();
}
}
}
if (stricmp(arg, "/M") == 0)
if (stricmp(arg, "/M") == 0 && opt == 1)
{
if (!mouse_en)
mouse_en = mouse_init();
}
}
else
{
printf("mouse initialized (/M):\t\t\t%i\n", mouse_en);
printf("mouse disabled (/D, /E - enable):\t%i\n", mouseopt_disabled);
printf("mouse external control (/C):\t\t%i\n", mouseopt_extctl);
printf("mouseopt [/M] [/C[0|1]] [/E[1|0]]\n\n");
printf("mouse initialized (/M):\t\t%i\n", mouse_en);
printf("mouse enabled (/E):\t\t%i\n", mouseopt_enabled);
printf("mouse external control (/C):\t%i\n", mouseopt_extctl);
}
}

Expand Down

0 comments on commit c816336

Please sign in to comment.