• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Feature Requests (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Repeat function for input line

This forum is now locked as we will no longer be developing the v1.x branch

Moderators: OldWolf, re*s.t.a.r.s.*2

Topic locked
4 posts • Page 1 of 1

Postby Troubadix » Sat Jan 06, 2007 2:15 pm

I think it would be a good idea to be able to repeat a line entered in the input field. Like on mirc which has a buffer where i can scroll thru the last inputs i made. It a nice feature if one enters a command and its not beeing executed because of an error. You just hit the arrow up key and it shows up again so one can correct and resend it. I think a buffer of the last 10 Lines would be enough. This buffer should be handled by the client.

Greetings
Thomas
Troubadix
Member
 
Posts: 25
Joined: Thu Jan 04, 2007 10:42 am
Location: Germany
  • Website
Top

Postby phpfreechat » Sat Jan 06, 2007 5:41 pm

I already implemnted this feature in the past but I had problems with keys to use.
I wanted to use up/down keycodes but these keycode was also used for other keyboard keys...
This is certainly a javascript problem and maybe it can be solved but I didn't found a workaround.

Maybe you can try ... the piece of code is into pfcclient.js :
into "initialize: function()" :
Code: Select all
    // this array contains all the sent command
    // used the up and down key to navigate in the history
    // (doesn't work on IE6)
    this.cmdhistory   = Array();
    this.cmdhistoryid = -1;
    this.cmdhistoryissearching = false;

into "doSendMessage: function()" :
Code: Select all
// append the string to the history
    this.cmdhistory.push(wval);
    this.cmdhistoryid = this.cmdhistory.length;
    this.cmdhistoryissearching = false;

into "callbackWords_OnKeypress: function(evt)" :
Code: Select all
    else if (code == 33 && false) // page up key
    {
      // write the last command in the history
      if (this.cmdhistory.length>0)
      {
        var w = this.el_words;
        if (this.cmdhistoryissearching == false && w.value != "")
          this.cmdhistory.push(w.value);
        this.cmdhistoryissearching = true;
        this.cmdhistoryid = this.cmdhistoryid-1;
        if (this.cmdhistoryid<0) this.cmdhistoryid = this.cmdhistory.length-1;
        w.value = this.cmdhistory[this.cmdhistoryid];
      }
    }
    else if (code == 34 && false) // page down key
    {
      // write the next command in the history
      if (this.cmdhistory.length>0)
      {
        var w = this.el_words;
        if (this.cmdhistoryissearching == false && w.value != "")
          this.cmdhistory.push(w.value);
        this.cmdhistoryissearching = true;
        this.cmdhistoryid = this.cmdhistoryid+1;
        if (this.cmdhistoryid>=this.cmdhistory.length) this.cmdhistoryid = 0;
        w.value = this.cmdhistory[this.cmdhistoryid];
      }
    }

To activate the non-working feature, just remove the "&& false" words in :
Code: Select all
else if (code == 33 && false)

and
Code: Select all
else if (code == 34 && false)

Keep me informed if you found something.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby Troubadix » Sat Jan 06, 2007 6:27 pm

Sorry, but I'm not a developer. I know just enough to insert patches and locate simple functions in simple code, but this chat is still to high for me. But maybe sombody else knows a solution.

Greetings
Thomas
Troubadix
Member
 
Posts: 25
Joined: Thu Jan 04, 2007 10:42 am
Location: Germany
  • Website
Top

Postby Troubadix » Wed Jan 10, 2007 9:19 pm

Hi Stéphan,

I changed the keycodes to 38 and 40 which are the arrow keys up and down. Also I put the code into the Key pressed area instead of key down. The keys you used are the Page up and down keys. I find this more convenient. It seems to work under FF2 and IE6. I didn't find any problems with other keys. Maybe this isn't the right way yet but i would say test it on diffrent keyboard layouts and against your known issues. Let me know if you find anything.

Code: Select all
  /**
   * Handle the pressed keys
   * see also callbackWords_OnKeypress
   */
  callbackWords_OnKeydown: function(evt)
  {
    if (!this.isconnected) return false;
    this.clearError(Array(this.el_words));
    var code = (evt.which) ? evt.which : evt.keyCode
    if (code == 9) /* tab key */
    {
      /* IE workaround : ignore TAB key here */
      /* do the nickname completion work like on IRC */
      this.completeNick();
      return false; /* do not leave the tab key default behavior */
    }
   else if (code == 38) // arrow up key
    {
      // write the last command in the history
      if (this.cmdhistory.length>0)
      {
        var w = this.el_words;
        if (this.cmdhistoryissearching == false && w.value != "")
          this.cmdhistory.push(w.value);
        this.cmdhistoryissearching = true;
        this.cmdhistoryid = this.cmdhistoryid-1;
        if (this.cmdhistoryid<0) this.cmdhistoryid = this.cmdhistory.length-1;
        w.value = this.cmdhistory[this.cmdhistoryid];
      }
    }
    else if (code == 40) // arrow down key
    {
      // write the next command in the history
      if (this.cmdhistory.length>0)
      {
        var w = this.el_words;
        if (this.cmdhistoryissearching == false && w.value != "")
          this.cmdhistory.push(w.value);
        this.cmdhistoryissearching = true;
        this.cmdhistoryid = this.cmdhistoryid+1;
        if (this.cmdhistoryid>=this.cmdhistory.length) this.cmdhistoryid = 0;
        w.value = this.cmdhistory[this.cmdhistoryid];
      }
    }    else
    {
      return true;
    }
  }

Link to tha activated keys: http://www.kreativverlag.de/chat/index.html
Greetings
Thomas
Last edited by Troubadix on Wed Jan 10, 2007 9:59 pm, edited 1 time in total.
Troubadix
Member
 
Posts: 25
Joined: Thu Jan 04, 2007 10:42 am
Location: Germany
  • Website
Top


Topic locked
4 posts • Page 1 of 1

Return to Feature Requests (v1.x)

Who is online

Users browsing this forum: No registered users and 4 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub