Code Monkey home page Code Monkey logo

Comments (10)

cronvel avatar cronvel commented on July 20, 2024

@b4dnewz Hmm... I don't see any error on my side... Can you post your code?

from terminal-kit.

b4dnewz avatar b4dnewz commented on July 20, 2024

yep sure @cronvel , the module is a fork of a module that isn't working anymore and i'm trying to fix by replacing it's internal functions with your module entirely (if possible).

I set the key bindings (for a particular screen) in this lines.

binding func and on event

this bindings catch 'b', 'p' and some other letters, than in a different "mode" or screen I take a input from the user so I call the off function but when I try to type something is still listening for 'b', 'p', etc..

So to resume quickly, in the main mode b (and other keys) are bound to actions, when I press b to change mode I unset the previous mode key bindings since it needs to take an input and every time I press b ti trigger the action function (that change screen) instead of catching b as input.

PS: the forked module is still under heavy development and refactoring so it's not working properly but that part is working right now.

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

@b4dnewz You are using .bind() to register the listener and the real function to stop listening:

this.term.on('key', this.listModeKeys.bind(this))
this.term.off('key', this.listModeKeys)

A Javascript function is not equal to its bounded version, that's why it doesn't work. ;)

from terminal-kit.

b4dnewz avatar b4dnewz commented on July 20, 2024

so I need to bind the context to the other funtion too? right?

edit: also, do you have a removeAll method or something like this?
edit2: I've tried to add .bind(this) to the off call but still not working

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

@b4dnewz No it would be two different bound functions again.

There are many solutions. One of them is to tranform Monitor.prototype.listModeKeys = function(key, matches, data) to a regular function listModeKeys(key, matches, data), and inside the Monitor() constructor assign this.listModeKeys = listModeKeys.bind( this ).

from terminal-kit.

b4dnewz avatar b4dnewz commented on July 20, 2024

thanks for the clarification @cronvel.
I will try to refactor my code.

from terminal-kit.

b4dnewz avatar b4dnewz commented on July 20, 2024

hey @cronvel do you use slack or any other chat? I would like if possible in some rare cases where the documentation (which is great) doesn't help me, to talk with you directly, is that possible?

many thanks in advance, I fixes it, right now I'm focused to make my fork version work exactly the same like previous but using your module, than I will refactor all the code and the logic.

from terminal-kit.

b4dnewz avatar b4dnewz commented on July 20, 2024

hi @cronvel, it's again me, I don't want to be boring and I don't want to open any other issue since are questions most of my troubles.

I'm trying to get the stdin and stdout from a socket client using node net module to create a server since node-telnet it's not updated, relies on node-buffers which it's not working.

I've spent a lot of hours right now trying to figure out how to pass the stdin and stdout to terminal-kit, right now I found only this example on stack overflow but it's not helping too much.

from the stack-overflow example re-adapted

var connect = require('net');
var client = connect.connect('80', 'localhost');
client.on('data', function(data) {
  process.stdin.once('data', function (chunk) {
    term(chunk.toString())
  });
})

Do you know if is possible? I've looked deep into the net documentation but without success..

Edit: The best thing I found until now it this answer but I can't figure out how to use this .pipe() method..and right now I must sleep :D

Many thanks in advance and sorry again for for all the trouble.

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

@b4dnewz Hi, you should use the terminal constructor.

This should work:

var termkit = require( 'terminal-kit' ) ;
var term = termkit.createTerminal( {
  stdin: yourSocket ,
  stdout: yourSocket ,
  stderr: yourSocket
} ) ;

After that, start using terminal-kit as usual.

BTW terminal-kit cannot detect the terminal correctly, and default to xterm-compatible.
If you know your terminal, you can set the appId option, which should match file's basenames found in the lib/termconfig/ directory of the lib.

from terminal-kit.

b4dnewz avatar b4dnewz commented on July 20, 2024

thanks @cronvel it's working good now!
on certain terminal less than on others but maybe it depends on my code, I will do further checks

from terminal-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.