1

I'm building a terminal application using blessed application in NodeJS.

Can anyone explain how to use the search option in list?

This is the list object I used:

var numlist = blessed.List({
  top: 23,
  left: 18,
  parent: screen,
  height: 8,
  width: 20,
  mouse: true,
  keys: true,
  vi: true,
  items: ["4","5","6"],
  border: {
    type: 'line'
  },
  style:{
    selected: {
      bg: 'blue',
      fg: 'white'
    },
    item:{
      bg: 'white',
      fg: 'blue'
    },
    focus:{
      bg: 'red'
    }
  }
});

This is the listener I wrote:

numlist.on('select', (item, index) => {});
Befeepilf
  • 617
  • 4
  • 10

1 Answers1

0

You can use the search option like this:


  const prompt = blessed.prompt({
    parent: screen,
    top: 'center',
    left: 'center',
    height: 'shrink',
    width: 'shrink',
    border: 'line',
  });

screen.append(prompt);
var numlist = blessed.List({
  top:23,
  left:18,
  parent:screen,
  height:8,
  width:20,
  mouse:true,
  keys:true,
  vi:true,
  items:["4","5","6"],
  search: function (callback) {
      prompt.input('Search:', '', function (err, value) {
        if (err) return;
        return callback(null, value);
      });
  }
});
Rajasegar
  • 86
  • 4