Skip to content

Commit

Permalink
Merge pull request #19 from adamyg/topic/buiild-225
Browse files Browse the repository at this point in the history
Topic/buiild 225; enhancements #16 and #17
  • Loading branch information
adamyg authored Mar 12, 2022
2 parents 2f4bf9d + bec5b92 commit 5288d24
Show file tree
Hide file tree
Showing 26 changed files with 470 additions and 131 deletions.
5 changes: 4 additions & 1 deletion mcsrc/lib/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,13 @@
#define PATH_SEP2 '\\'
#define PATH_SEP_STR2 "\\"
#define IS_PATH_SEP(c) ((c) == PATH_SEP || (c) == PATH_SEP2)
#define PATH_ENV_SEP ';'
extern char *strrchr2(const char *s, int c1, int c2);
extern char *strchr2(const char *s, int c1, int c2);
#else
#define IS_PATH_SEP(c) ((c) == PATH_SEP)
#endif
#define PATH_ENV_SEP ':'
#endif
#define TMPDIR_DEFAULT "/tmp"
#define SCRIPT_SUFFIX ""
#define get_default_editor() "vi"
Expand Down
2 changes: 2 additions & 0 deletions mcsrc/lib/tty/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ extern const key_code_name_t key_name_conv_tab[];

extern int old_esc_mode_timeout;

extern int console_alert_mode; //WIN32, alert-mode

extern int double_click_speed;
extern gboolean old_esc_mode;
extern gboolean use_8th_bit_as_meta;
Expand Down
7 changes: 2 additions & 5 deletions mcsrc/lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,8 @@ x_basename (const char *s)
const char *url_delim, *path_sep;

url_delim = g_strrstr (s, VFS_PATH_URL_DELIMITER);
#if defined(WIN32)
{ const char *s1 = strrchr (s, PATH_SEP),
*s2 = strrchr (s, PATH_SEP2);
path_sep = (s2 > s1 ? s2 : s1);
}
#if defined(WIN32) //WIN32, path
path_sep = strrchr2 (s, PATH_SEP, PATH_SEP2);
#else
path_sep = strrchr (s, PATH_SEP);
#endif
Expand Down
10 changes: 7 additions & 3 deletions mcsrc/lib/widget/input_complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ filename_completion_function (const char *text, int state, input_complete_t flag
g_free (users_dirname);
vfs_path_free (dirname_vpath, TRUE);

#if defined(WIN32) //WIN32, path
if ((*text != '\0') && (temp = strrchr2 (text, PATH_SEP, PATH_SEP2)) != NULL)
#else
if ((*text != '\0') && (temp = strrchr (text, PATH_SEP)) != NULL)
#endif
{
filename = g_strdup (++temp);
dirname = g_strndup (text, temp - text);
Expand Down Expand Up @@ -944,13 +948,13 @@ try_complete_all_possible (try_complete_automation_state_t * state, char *text,

cdpath_ref = g_strdup (getenv ("CDPATH"));
cdpath = cdpath_ref;
c = (cdpath == NULL) ? '\0' : ':';
c = (cdpath == NULL) ? '\0' : PATH_ENV_SEP;

while (matches == NULL && c == ':')
while (matches == NULL && c == PATH_ENV_SEP)
{
char *s;

s = strchr (cdpath, ':');
s = strchr (cdpath, PATH_ENV_SEP);
/* cppcheck-suppress nullPointer */
if (s == NULL)
s = strchr (cdpath, '\0');
Expand Down
126 changes: 119 additions & 7 deletions mcsrc/src/filemanager/boxes.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ configure_box (void)
#if defined(WIN32) //WIN32, quick
quick_widget_t quick_widgets[35+2] = {0},
*qc = quick_widgets;

#else
quick_widget_t quick_widgets[] = {
/* *INDENT-OFF* */
Expand Down Expand Up @@ -1189,6 +1190,86 @@ display_bits_box (void)
/* --------------------------------------------------------------------------------------------- */
#else /* HAVE_CHARSET */

#if defined(WIN32) //WIN32, alert-options
static unsigned long visible_option_id, audible_beep_id, legacy_beep_id;

static void
alert_options_decode (int *visible_option, int *audible_beep, int *legacy_beep)
{
*visible_option = *audible_beep = *legacy_beep = 0;

if (SLTT_BEEP_FLASH & console_alert_mode) *visible_option = 1;
else if (SLTT_BEEP_INVERT & console_alert_mode) *visible_option = 2;
if (SLTT_BEEP_AUDIBLE & console_alert_mode)
{
*audible_beep = 1;
if (SLTT_BEEP_LEGACY & console_alert_mode)
*legacy_beep = 1;
}
}

static void
alert_options_apply (int visible_option, int audible_beep, int legacy_beep)
{
console_alert_mode = 0;
if (1 == visible_option) console_alert_mode |= SLTT_BEEP_FLASH;
else if (2 == visible_option) console_alert_mode |= SLTT_BEEP_INVERT;
if (audible_beep)
{
console_alert_mode |= SLTT_BEEP_AUDIBLE;
if (legacy_beep)
console_alert_mode |= SLTT_BEEP_LEGACY;
}
}

static void
alert_options_test (Widget * w)
{
const int old_console_alert_mode = console_alert_mode;
const int t_visible_option = RADIO(widget_find_by_id(w, visible_option_id))->sel;
const int t_audible_beep = CHECK(widget_find_by_id(w, audible_beep_id))->state;
const int t_legacy_beep = CHECK(widget_find_by_id(w, legacy_beep_id))->state;

alert_options_apply (t_visible_option, t_audible_beep, t_legacy_beep);
tty_beep ();
console_alert_mode = old_console_alert_mode;
}

static cb_ret_t
display_bits_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
switch (msg)
{
case MSG_NOTIFY:
/* message from "Single press" checkbutton */
if (sender != NULL)
{
if (sender->id == audible_beep_id)
{
const gboolean not_single = !CHECK (sender)->state;
Widget *ww;

/* input line */
ww = widget_find_by_id (w, legacy_beep_id);
widget_disable (ww, not_single);

alert_options_test (w);
return MSG_HANDLED;
}
else if (sender->id == visible_option_id || sender->id == legacy_beep_id)
{
alert_options_test (w);
return MSG_HANDLED;
}
}
return MSG_NOT_HANDLED;

default:
return dlg_default_callback (w, sender, msg, parm, data);
}
}
#endif //WIN32

void
display_bits_box (void)
{
Expand All @@ -1203,7 +1284,7 @@ display_bits_box (void)
gboolean new_meta;

#if defined(WIN32) //WIN32, quick
quick_widget_t quick_widgets[9+2] = {0},
quick_widget_t quick_widgets[19+2] = {0},
*qc = quick_widgets;
#else
quick_widget_t quick_widgets[] = {
Expand All @@ -1219,23 +1300,50 @@ display_bits_box (void)
QUICK_END
/* *INDENT-ON* */
};

quick_dialog_t qdlg = {
-1, -1, 46,
N_("Display bits"), "[Display bits]",
quick_widgets, NULL, NULL};
};
#endif //WIN32,quick

#if defined(WIN32) //WIN32, quick/alert-options
quick_dialog_t qdlg = {
-1, -1, 46,
N_("Display bits"), "[Display bits]",
quick_widgets, NULL, NULL
quick_widgets, display_bits_callback, NULL};

const char *visible_options[] = {
N_("Invisible"),
N_("Flash window"),
N_("Flash baseline")
};

#if defined(WIN32) //WIN32, quick
const int visible_num = G_N_ELEMENTS (visible_options);
int visible_option, audible_beep, legacy_beep;

alert_options_decode (&visible_option, &audible_beep, &legacy_beep);

qc = XQUICK_START_COLUMNS (qc),
qc = XQUICK_LABEL (qc, N_("Input / display codepage:"), NULL),
qc = XQUICK_LABEL (qc, N_("Input / display codepage:"), NULL),
qc = XQUICK_NEXT_COLUMN (qc),
qc = XQUICK_BUTTON (qc, cpname, B_USER, sel_charset_button, NULL),
qc = XQUICK_BUTTON (qc, cpname, B_USER, sel_charset_button, NULL),
qc = XQUICK_STOP_COLUMNS (qc),
qc = XQUICK_SEPARATOR (qc, TRUE),
qc = XQUICK_CHECKBOX (qc, N_("F&ull 8 bits input"), &new_meta, NULL),
qc = XQUICK_START_COLUMNS (qc),
qc = XQUICK_START_GROUPBOX (qc, N_("Console alert mode")),
qc = XQUICK_RADIO (qc, visible_num, visible_options, &visible_option, &visible_option_id),
qc = XQUICK_CHECKBOX (qc, N_("Audible"), &audible_beep, &audible_beep_id),
qc = XQUICK_CHECKBOX (qc, N_("Legacy beep"), &legacy_beep, &legacy_beep_id),
qc = XQUICK_STOP_GROUPBOX (qc),
qc = XQUICK_NEXT_COLUMN (qc),
qc = XQUICK_START_GROUPBOX (qc, N_("Other Options")),
qc = XQUICK_CHECKBOX (qc, N_("F&ull 8 bits input"), &new_meta, NULL),
qc = XQUICK_STOP_GROUPBOX (qc),
qc = XQUICK_STOP_COLUMNS (qc),
qc = XQUICK_BUTTONS_OK_CANCEL (qc),

qc = XQUICK_END (qc);
assert(qc == (quick_widgets + (sizeof(quick_widgets)/sizeof(quick_widgets[0]))));
#endif //WIN32, quick
Expand All @@ -1256,13 +1364,17 @@ display_bits_box (void)
g_free (errmsg);
}

#if defined(WIN32) //WIN32, alert-options
alert_options_apply (visible_option, audible_beep, legacy_beep);
#endif

#ifdef HAVE_SLANG
tty_display_8bit (mc_global.display_codepage != 0 && mc_global.display_codepage != 1);
#else
tty_display_8bit (mc_global.display_codepage != 0);
#endif
use_8th_bit_as_meta = !new_meta;

repaint_screen ();
}
}
Expand Down
6 changes: 3 additions & 3 deletions mcsrc/src/filemanager/cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ handle_cdpath (const char *path)

cdpath = g_strdup (getenv ("CDPATH"));
p = cdpath;
c = (p == NULL) ? '\0' : ':';
c = (p == NULL) ? '\0' : PATH_ENV_SEP;

while (!result && c == ':')
while (!result && c == PATH_ENV_SEP)
{
char *s;

s = strchr (p, ':');
s = strchr (p, PATH_ENV_SEP);
if (s == NULL)
s = strchr (p, '\0');
c = *s;
Expand Down
3 changes: 3 additions & 0 deletions mcsrc/src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ static const struct
{ "mouse_repeat_rate", &mou_auto_repeat },
{ "double_click_speed", &double_click_speed },
{ "old_esc_mode_timeout", &old_esc_mode_timeout },
#if defined(WIN32) //WIN32, alert-options
{ "console_alert_mode", &console_alert_mode },
#endif
{ "max_dirt_limit", &mcview_max_dirt_limit },
{ "num_history_items_recorded", &num_history_items_recorded },
#ifdef ENABLE_VFS
Expand Down
1 change: 1 addition & 0 deletions mcwin32/.cvsignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.makelib
include
patch
ref
bin
bin.*
lib.*
Expand Down
4 changes: 3 additions & 1 deletion mcwin32/.gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
.makelib/
include/
patch/
bin/
ref/
bin
bin.*/
lib.*/
objects*/
msvc*/
libglib_*/
crash/
CVS/
bin_shortcut.lnk
Makefile
buildinfo.h
BUILDNUMBER
Expand Down
35 changes: 35 additions & 0 deletions mcwin32/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
Pending build-225

Fri Mar 11 21:41:28 2022 adamy

* #16 - Completion

o Support unix and windows directory separator.
o CDPATH delimiter.

Wed Mar 9 21:50:55 2022 adamy

* Console alert mode (#17 - Console alert options, audible and/or visible indicator).

o Configuration, under <Display Bits>

- Visible indicators <Invisible, Flash window or Flash baseline> [default = Invisible].
- Audible <on/off> [default = on].

+-------------------- Display bits -------------------+
| Input / display codepage: [ UTF-8 ] |
|-----------------------------------------------------|
| Console alert mode Other Options |
| ( ) Invisible [x] Full 8 bits input |
| ( ) Flash window |
| (*) Flash baseline |
| [ ] Audible |
| [ ] Legacy beep |
|-----------------------------------------------------|
| [< OK >] [ Cancel ] |
+-----------------------------------------------------+

o "console_alert_mode", configuration element (save/restore).
o Supporting slang extensions.
o Utilise windows "SystemAsterisk".

Sun Mar 6 21:19:10 2022 adamy

* Build-224
Expand Down
1 change: 1 addition & 0 deletions mcwin32/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ MC_LIBMC=\
$(D_OBJMC)/tty_tty$(O) \
\
$(D_OBJMC)/compat_strtok_r$(O) \
$(D_OBJMC)/strchr2$(O) \
$(D_OBJMC)/win32_key$(O) \
$(D_OBJMC)/win32_tty$(O) \
$(D_OBJMC)/win32_win$(O) \
Expand Down
6 changes: 6 additions & 0 deletions mcwin32/TODO.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Sat Mar 5 17:41:51 2022 adamy

* fish support

Tue Jun 9 13:22:00 2020 adamy

* Mirror MC configuration during builds, example
Expand Down Expand Up @@ -48,3 +52,5 @@ Wed Mar 8 02:55:35 2017 adamy
* MISSING: lzip and lz4 decompression support, research options.

* sfs, zip support.

#end
Loading

0 comments on commit 5288d24

Please sign in to comment.