source/index.js
/**
 * Function reads a note and adds it to the list
 */
Function reads a note and adds it to the list
Function reads a note and adds it to the list
function addNote() {
  let prompt = blessed.prompt({
    parent: screen,
    top: 'center',
    left: 'center',
    width: '50%',
    draggable: true,
    height: 8,
    border: {
      type: theme.border ? 'line' : 'none'
    },
    style: {
      fg: theme.textColor,
      bg: theme.backgroundColor,
      border: {
        fg: theme.borderColor
      }
    }
  });
  prompt._.input.cancel = function() {
    infoWrapper.content = `log: event handler called`;
    screen.render();
    this.clearValue();
    this.prototype.cancel();
  };
  prompt.readInput('Enter a note to add', '', err => {
    if (err != undefined) {
      infoWrapper.content = `error occured: ${err.message.toLowerCase()}`;
      prompt.destroy();
      screen.render();
    } else if (
      prompt._.input.value != undefined &&
      prompt._.input.value !== ''
    ) {
      const text = prompt._.input.value;
      notes.add(text, noteWrapper.selectedIndex);
      noteWrapper.setItems(
        notes.toArray().map((entry, index) => `${index + 1}) ${entry}`)
      );
      noteWrapper.focus();
      prompt.destroy();
      infoWrapper.content = 'done! c:';
      screen.render();
    } else {
      prompt.destroy();
      infoWrapper.content = 'cancelled';
      screen.render();
    }
  });
}
function addNote ( ) { let prompt = blessed . prompt ( { parent : screen , top : 'center' , left : 'center' , width : '50%' , draggable : true , height : 8 , border : { type : theme . border ? 'line' : 'none' } , style : { fg : theme . textColor , bg : theme . backgroundColor , border : { fg : theme . borderColor } } } ) ; prompt . _ . input . cancel = function ( ) { infoWrapper . content = ` ` ; screen . render ( ) ; this . clearValue ( ) ; this . prototype . cancel ( ) ; } ; prompt . readInput ( 'Enter a note to add' , '' , err => { if ( err != undefined ) { infoWrapper . content = ` ${ err . message . toLowerCase ( ) } ` ; prompt . destroy ( ) ; screen . render ( ) ; } else if ( prompt . _ . input . value != undefined && prompt . _ . input . value !== '' ) { const text = prompt . _ . input . value ; notes . add ( text , noteWrapper . selectedIndex ) ; noteWrapper . setItems ( notes . toArray ( ) . map ( ( entry , index ) => ` ${ index + 1 } ${ entry } ` ) ) ; noteWrapper . focus ( ) ; prompt . destroy ( ) ; infoWrapper . content = 'done! c:' ; screen . render ( ) ; } else { prompt . destroy ( ) ; infoWrapper . content = 'cancelled' ; screen . render ( ) ; } } ) ; }
Function reads a note and adds it to the list
Function reads a note and adds it to the list
//TODO: fix a bug in textarea submit/cancel methods /* Error occured */ /* Confirmed */ /* Cancelled */