Keyboard input / init + questions

Jerome Martin tramjoe.merin at gmail.com
Sun Sep 26 12:40:40 PDT 2010


Hi again,

As promised I experimented a bit on my side....

1) I upgraded to git version, still no luck with the keyboard messup with
init (from sysvinit debian squeeze) when it starts the rc2.d after rcS
execution.

2) I experimented with getting the arrow keys working:

 - Disabled the key capture in main.c. What I have in mind is to replace
that by additional hooks in the script file, with proper SetXXXCallback
functions to restore the details view, etc.
 - Added some logic in the scan code to understand c-like "\XXX" where XXX
is an octal number. I had to disabled the simple '\0' case for that (the
logic of the scan code is not very kin to supporting both, so I got lazy,
but that could be implemented too), so with my patches you need to use
"\000" instead. Just for fun I also added a XOR method to the script String
object, so you can use things like "\100".XOR("[") in a script.

3) On the script side, the logic to properly get ANSI escape sequences while
still being able to capture single escape characters or single '[' normally
looks like the following. Here the up and down keys trigger scrolling my log
viewer...

fun refresh_callback () {
  # Animate our icons
  [..]

  # Keyboard mod delays decrement
  if (escape_mod_delay > 0) {
    escape_mod_delay--;
    if (escape_mod_delay == 0) {
      inkey_callback("ESC");
    }
  }
  if (ansi_mod_delay > 0) { ansi_mod_delay--; }
}


# Allows parts of an escape sequence to arrive at 1/25th second interval
compose_keys_delay = 2;
escape_mod_delay = 0;
ansi_mod_delay = 0;

fun inkey_callback (key) {
  if (key == "ESC") {
    key = "\033";
  # The following "\033" could be written "\100".XOR("[")
  } else if (key == "\033" && escape_mod_delay == 0) {
    escape_mod_delay = compose_keys_delay;
    key = "";
  } else if (key == "[" && escape_mod_delay > 0) {
      ansi_mod_delay = compose_keys_delay;
      escape_mod_delay = 0;
      key = "";
  } else if (ansi_mod_delay > 0) {
    if (key == "A") {
      key = "UP";
    } else if (key == "B") {
      key = "DOWN";
    } else if (key == "C") {
      key = "LEFT";
    } else if (key == "D") {
      key = "RIGHT";
    }
    ansi_mod_delay = 0;
  }

  if (key == "UP") {
    if (log_view_pos == -1) {
      log_view_pos = log_len - display_len;
    }
    log_view_pos--;
    if (log_view_pos < 1)
      log_view_pos = 0;
    display_log();
  } else if (key == "DOWN")  {
    if (log_view_pos != -1) {
      log_view_pos++;
      if (log_view_pos > log_len - display_len) {
        log_view_pos = -1;
      } else {
        display_log();
      }
    }
  } else if (key != "") {
    toggle_help();
  }
}

And the patches themselves in attached file...

4) About my questions on string handling, I think I am now familiar enough
with plymouth script parser to implement what I need myself. I noticed
 SubString() and a CharAt() methods already, I will probably add a Len() one
for my needs. I was also going to ask a question about fonts, but it seems
that the Image.Text() has already been augmented to handle font selection,
so I am all set there :-) the current git version certainly deserves a
proper release and some documentation though ...

5) As a sidenote, I did a quick debian packaging of the git version, but had
to adapt a bit the debian package rules from squeeze because it assumed that
plymouth original sources already had autoconf ran there, when those that I
downloaded had an autogen.sh script ... This is weird, and it is either an
unclean package in debian OR the fact that you released last time with
autogen.sh already ran. Is that the case ?

Best Regards,
-- 
Jérôme Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/plymouth/attachments/20100926/e3cf86cc/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plymouth_0.8.4-1.diff
Type: text/x-patch
Size: 7274 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/plymouth/attachments/20100926/e3cf86cc/attachment.bin>


More information about the plymouth mailing list