diff options
author | Dave Davenport <qball@gmpclient.org> | 2018-02-08 17:56:31 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2018-02-08 17:56:31 +0100 |
commit | 0f1717f829e95d7f3e1ac5b213d3f73f09b0da62 (patch) | |
tree | be57a198fd20cf6751f307ac4bac87f54462712d | |
parent | 521843e9be17686624fbeef973e5cd0f520f02d1 (diff) |
[Script] Reset highlighting when reload view
Issue: #767
-rwxr-xr-x | Examples/test_script_mode.sh | 35 | ||||
-rw-r--r-- | source/dialogs/script.c | 17 |
2 files changed, 39 insertions, 13 deletions
diff --git a/Examples/test_script_mode.sh b/Examples/test_script_mode.sh index 61e29141..a58ef83e 100755 --- a/Examples/test_script_mode.sh +++ b/Examples/test_script_mode.sh @@ -1,17 +1,28 @@ #!/usr/bin/env bash -echo -en "\x00prompt\x1ftesting\n" -echo -en "\0urgent\x1f0,2\n" -echo -en "\0active\x1f1\n" -echo -en "\0markup-rows\x1ftrue\n" -echo -en "\0message\x1fSpecial <b>bold</b>message\n" +if [ x"$@" = x"quit" ] +then + exit 0 +fi -echo "aap" -echo "noot" -echo "mies" -echo "testing" -echo "<b>Bold</b>" -if [ -n "$@" ] +if [ "$@" ] then - echo "$@" + for a in {1..10} + do + echo "$a" + done + echo "quit" +else + echo -en "\x00prompt\x1ftesting\n" + echo -en "\0urgent\x1f0,2\n" + echo -en "\0active\x1f1\n" + echo -en "\0markup-rows\x1ftrue\n" + echo -en "\0message\x1fSpecial <b>bold</b>message\n" + + echo "aap" + echo "noot" + echo "mies" + echo "testing" + echo "<b>Bold</b>" + echo "quit" fi diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 9daf1354..4f53ee3e 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -78,7 +78,7 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length ) char *value = line + length_key + 1; if ( strcasecmp ( line, "message" ) == 0 ) { g_free ( pd->message ); - pd->message = g_strdup ( value ); + pd->message = strlen(value)? g_strdup ( value ):NULL; } else if ( strcasecmp ( line, "prompt" ) == 0 ) { g_free ( pd->prompt ); @@ -187,6 +187,19 @@ static unsigned int script_mode_get_num_entries ( const Mode *sw ) return rmpd->cmd_list_length; } +static void script_mode_reset_highlight ( Mode *sw ) +{ + ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; + + rmpd->num_urgent_list = 0; + g_free ( rmpd->urgent_list ); + rmpd->urgent_list = NULL; + rmpd->num_active_list = 0; + g_free ( rmpd->active_list ); + rmpd->active_list = NULL; + +} + static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line ) { ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; @@ -204,9 +217,11 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned retv = ( mretv & MENU_LOWER_MASK ); } else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) { + script_mode_reset_highlight ( sw ); new_list = execute_executor ( sw, rmpd->cmd_list[selected_line], &new_length ); } else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) { + script_mode_reset_highlight ( sw ); new_list = execute_executor ( sw, *input, &new_length ); } |