Hi!

Didn't see this until now.

I moved the phone-input into a seperate class, and should now be usable
for others. It does no drawing of any kind, only handles the input. All
string handling is done in unicode. The key-input list is translatable
with the std. i18n.

For a demo of usage, see the mailwriter.py file in > mail-0.5a.

I'll be gone for the weekend, so I won't be able to reply to any mails
until then.


Regards Viggo Fredriksen

Gustavo Sverzut Barbieri wrote:
--- Jan Grewe <[EMAIL PROTECTED]> escreveu:

Hi craig,
There is a plugin out there, the freevo mailreader, which supports
replying
to a mail via cellphone-style text input, so there _is_ at least a
way of
typing something, let's hope that someone writes a module for other
plugins
(viggo, you hear me? ;->)...

/jan


Rob is working on PyUI integration, it could help a lot.

In mean time, we could have something to, in some plugin/area, remap
every key a-z0-9 to give the input while in one "widget", so people
with wireless keyboards could type things easily. Viggo, could you take
a look at it and try to implement? It should be just a matter of
changing config.EVENTS and then restore it.
   But in meantime, it would be cool to have viggo mini-keyboard
"componentized"

Gustavo

______________________________________________________________________

Yahoo! Mail - O melhor e-mail do Brasil! Abra sua conta agora:
http://br.yahoo.com/info/mail.html


------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Freevo-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-devel

#if 0 /*
# -----------------------------------------------------------------------
# PhoneInput.py - A class handling multitap input from a remote
# Author: Viggo Fredriksen <[EMAIL PROTECTED]>
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ----------------------------------------------------------------------- */
#endif

import rc, time
from event import *

class PhoneInput:
    """
    This class takes care of mobilephone style input.
    All characters can be customized by gettext
    """
    dInput = {}
    KEY    = ['','','','','','','','','','']

    # default keymap
    KEY[1] = _('-|?|!|,|.|:|;|<|=|>|(|)|_|1')
    KEY[2] = _('a|b|c|2')
    KEY[3] = _('d|e|f|3')
    KEY[4] = _('g|h|i|4')
    KEY[5] = _('j|k|l|5')
    KEY[6] = _('m|n|o|6')
    KEY[7] = _('p|q|r|s|7')
    KEY[8] = _('t|u|v|8')
    KEY[9] = _('w|x|y|z|9')
    KEY[0] = _(' |+|&|@|/|\\')

    def __init__(self, parent):
        rc.app(self)
        rc.set_context('input')
        self.parent = parent
        self._initialize_()

        k = 0
        for v in self.KEY:
            self.dInput[k] = v.split('|')
            k += 1

    def _initialize_(self):
        self.timer     = 0
        self.timeout   = 1
        self.selected  = 0
        self.position  = 0
        self.text      = ['|']
        self.sel_char  = ''
        self.last_key  = None
        self.caret     = '|'
        self.uppercase = True

    def _getChar_(self, key, index, upper=False):
        c = self.dInput.get(key)[index]
        if upper: c = c.upper()
        return c

    def _select_(self, key):
        now = time.time()

        if self.timer == 0:
            self.timer = now

        if key != self.last_key:
            # move to next char and start new timer
            self.last_key = key
            self.selected = 0
            self.sel_char = self._getChar_(key, 0)

            char = self._getChar_(self.last_key, 0, self.uppercase)
            self._set_char_(char)

        elif ((now-self.timer)>self.timeout):
            # move to next char
            char = self._getChar_(self.last_key, self.selected, self.uppercase)
            self._set_char_(char)

            self.last_key = key
            self.sel_char = ''
            self.selected = 0
        else:
            self.last_key  = key
            self.selected += 1

            if self.selected>(len(self.dInput[key])-1):
                self.selected = 0

            char = self._getChar_(key, self.selected, self.uppercase)

            self.text[self.position-1] = char

        self.timer = now

    def _set_char_(self, char):
        if self.position < (len(self.text)-1):
            self.text.insert(self.position, char)
        else:
            self.text[self.position] = char
            self.text.append('|')
        self.position += 1

    def _reset_(self):
        self.last_key = '123123'
        self.selected = 0
        self.timer    = 0

    def exit(self):
        # quits the app
        self._initialize_()
        rc.app(None)

    def toggle_upper(self):
        # toggle inputchars casing
        if self.uppercase: self.uppercase = False
        else:              self.uppercase = True

    def move_left(self):
        self._reset_()
        if self.position > 0:
            del self.text[self.position]
            self.position -= 1
            self.text.insert(self.position, '|')

    def move_right(self):
        self._reset_()
        if self.position < len(self.text)-1:
            del self.text[self.position]
            self.position += 1
            self.text.insert(self.position, '|')

    def insert_newline(self):
        # insert a linebreak
        self._reset_()
        self._set_char_(u'\n')

    def remove_char(self):
        # erase character
        self._reset_()
        if self.position > 0:
            self.position -= 1
            del self.text[self.position]

    def getInputString(self):
        # get the text input
        return Unicode(''.join(self.text))

    def getString(self):
        # get the text without caret
        ret = self.text
        del ret[self.position]
        return Unicode(''.join(ret))

    def getStringArray(self):
        # get the text as array without caret
        ret = self.text
        del ret[self.position]
        return ret

    def getInputStringArray(self):
        # get the text as array with caret
        return self.text

    def getLength(self):
        # get length of textarray without the caret
        return len(self.text) - 1

    def getPosition(self):
        # get the position
        return self.position

    def eventhandler(self, event, menuw=None, arg=None):
        if event == INPUT_1:
            self._select_(1)
        elif event == INPUT_2:
            self._select_(2)
        elif event == INPUT_3:
            self._select_(3)
        elif event == INPUT_4:
            self._select_(4)
        elif event == INPUT_5:
            self._select_(5)
        elif event == INPUT_6:
            self._select_(6)
        elif event == INPUT_7:
            self._select_(7)
        elif event == INPUT_8:
            self._select_(8)
        elif event == INPUT_9:
            self._select_(9)
        elif event == INPUT_0:
            self._select_(0)

        # send all events to the parent
        return self.parent.eventhandler(event, arg=arg)

Reply via email to