Exemplo n.º 1
0
char				*ft_term(t_shell *shell, int j, int f)
{
	char			buf[5];
	t_line			*tmp;
	char			*str;

	tmp = shell->hist;
	str = NULL;
	ft_putstr(tgetstr("sc", NULL));
	f = 0;
	while (42)
	{
		ft_read(buf);
		if (buf[0] == '\n')
			return (exit_mode(shell, str, j));
		else if (K_UP(buf))
			f *= history(&tmp, 'A', &str);
		else if (K_DOWN(buf))
			f *= history(&tmp, 'B', &str);
		else if (K_END(buf))
			f = 0;
		else if (K_HOME(buf))
			f = ft_strlen(str);
		else
			term_center(shell, &str, buf, &f);
	}
	return (str);
}
Exemplo n.º 2
0
void Element::refreshMedia() {
	_flags &= ~Flag::HiddenByGroup;

	const auto item = data();
	const auto media = item->media();
	if (media && media->canBeGrouped()) {
		if (const auto group = history()->owner().groups().find(item)) {
			if (group->items.back() != item) {
				_media = nullptr;
				_flags |= Flag::HiddenByGroup;
			} else {
				_media = std::make_unique<HistoryGroupedMedia>(
					this,
					group->items);
				if (!pendingResize()) {
					history()->owner().requestViewResize(this);
				}
			}
			return;
		}
	}
	if (_data->media()) {
		_media = _data->media()->createView(this);
	} else {
		_media = nullptr;
	}
}
Exemplo n.º 3
0
char *
fetchline(void)
{
	static EditLine	*el;
	static History	*hist;
	HistEvent	hevent;
	char		*line;
	int		count;

	if (!el) {
		hist = history_init();
		history(hist, &hevent, H_SETSIZE, 100);
		el = el_init(progname, stdin, stdout, stderr);
		el_source(el, NULL);
		el_set(el, EL_SIGNAL, 1);
		el_set(el, EL_PROMPT, el_get_prompt);
		el_set(el, EL_HIST, history, (const char *)hist);
	}
	line = strdup(el_gets(el, &count));
	if (line) {
		if (count > 0)
			line[count-1] = '\0';
		if (*line)
			history(hist, &hevent, H_ENTER, line);
	}
	return line;
}
Exemplo n.º 4
0
void initialize_libedit(const char *prog)
{
	/* Init the builtin history */
	hist = history_init();

	/* Remember 100 events */
#ifdef XDC_OLD_LIBEDIT
	history(hist, XDC_H_SETSIZE, 100);
#else
	history(hist, &ev, XDC_H_SETSIZE, 100);
#endif

	/* Initialize editline */
#ifdef XDC_OLD_LIBEDIT
	el = el_init(prog, stdin, stdout);
#else
	el = el_init(prog, stdin, stdout, stderr);
#endif

	el_set(el, EL_EDITOR, "emacs");    /* Default editor is emacs   */
	el_set(el, EL_SIGNAL, 1);          /* Handle signals gracefully */
	el_set(el, EL_PROMPT, get_prompt); /* Set the prompt function   */

	/* Tell editline to use this history interface */
	el_set(el, EL_HIST, history, hist);

	/*
	 * Source the user's defaults file.
	 */
	/* el_source(el, "xdebug"); */
}
Exemplo n.º 5
0
void HistoryItem::markMediaRead() {
	_flags &= ~MTPDmessage::Flag::f_media_unread;

	if (mentionsMe()) {
		history()->updateChatListEntry();
		history()->eraseFromUnreadMentions(id);
	}
}
Exemplo n.º 6
0
void ViewWindow::updateHistoryIcons()
{
	if ( mainWindow )
	{
		mainWindow->navSetBackEnabled( history()->canGoBack() );
		mainWindow->navSetForwardEnabled( history()->canGoForward() );
	}
}
Exemplo n.º 7
0
Element::~Element() {
	if (_data->mainView() == this) {
		_data->clearMainView();
	}
	if (_context == Context::History) {
		history()->owner().notifyViewRemoved(this);
	}
	history()->owner().unregisterItemView(this);
}
Exemplo n.º 8
0
void HistoryMessage::addToUnreadMentions(UnreadMentionType type) {
	if (IsServerMsgId(id) && mentionsMe() && isMediaUnread()) {
		if (history()->addToUnreadMentions(id, type)) {
			Notify::peerUpdatedDelayed(
				history()->peer,
				Notify::PeerUpdate::Flag::UnreadMentionsChanged);
		}
	}
}
Exemplo n.º 9
0
bool HistoryItem::suggestReport() const {
	if (out() || serviceMsg() || !IsServerMsgId(id)) {
		return false;
	} else if (const auto channel = history()->peer->asChannel()) {
		return true;
	} else if (const auto user = history()->peer->asUser()) {
		return user->botInfo != nullptr;
	}
	return false;
}
Exemplo n.º 10
0
void
add_history(char *p)
{
#ifdef H_SETSIZE
    HistEvent ev;
    history(h, &ev, H_ENTER, p);
#else
    history(h, H_ENTER, p);
#endif
}
Exemplo n.º 11
0
void TESession::clearHistory()
{
  if (history().isOn()) {
    int histSize = history().getSize();
    setHistory(HistoryTypeNone());
    if (histSize)
      setHistory(HistoryTypeBuffer(histSize));
    else
      setHistory(HistoryTypeFile());
  }
}
Exemplo n.º 12
0
Arquivo: complete.c Projeto: danrl/nsh
/*
 * this needs to be called before initedit()
 */
void
inithist()
{
	if (!histc) {
		histc = history_init();	/* init the builtin history */
		history(histc, &ev, H_SETSIZE, 100); /* remember 100 events */
	}
	if (!histi) {
		histi = history_init();
		history(histi, &ev, H_SETSIZE, 100);
	}
}
Exemplo n.º 13
0
void WorkThread::run()
{
    /*********************************************************/
    /* Read input file, and initialize params and vars. This */
    /* function calls SPECIES and LOAD or Restore            */
    start_(argc, argv);

   // init output file
    QString filename = "Qdust(t).txt";
    QFile file(filename);


   // InitWindows(argc, argv);

    history();
    fields();

    int step=0;
    float *pot = phi;
    if (file.open(QIODevice::WriteOnly)) {
        QTextStream stream(&file);
        stream.setRealNumberPrecision(20);

        while(True)
        {
          if(!stop){
//            mutex.lock();
              t += dt;

              move();
              adjust();
              mcc();
              fields();
              history();

              if(((int)(t/dt))%2==0) stream << t<<"\t"<< qdust << "\t"<< energy_flux[0] <<"\t"<<  energy_flux[1] << endl;

              updatePlasmaModel();

             if(step%200==0 && step>0) {
//                 stop=true;
                 std::cout<< "Step "<<step<<": a signal sent to save data\n"<<endl;
                 emit DataChanged();
             }

            } else{
                this->msleep(50);
            }
            step++;
        }
    }
}
Exemplo n.º 14
0
Element::Element(
	not_null<ElementDelegate*> delegate,
	not_null<HistoryItem*> data)
: _delegate(delegate)
, _data(data)
, _dateTime(ItemDateTime(data))
, _context(delegate->elementContext()) {
	history()->owner().registerItemView(this);
	refreshMedia();
	if (_context == Context::History) {
		history()->setHasPendingResizedItems();
	}
}
Exemplo n.º 15
0
void
sethistsize(const char *hs)
{
	int histsize;
	HistEvent he;

	if (hist != NULL) {
		if (hs == NULL || *hs == '\0' ||
		   (histsize = atoi(hs)) < 0)
			histsize = 100;
		history(hist, &he, H_SETSIZE, histsize);
		history(hist, &he, H_SETUNIQUE, 1);
	}
}
Exemplo n.º 16
0
void
sethistsize(const char *hs)
{
	int histsize;
	HistEvent he;

	if (hist != NULL) {
		if (hs == NULL || !is_number(hs))
			histsize = 100;
		else
			histsize = atoi(hs);
		history(hist, &he, H_SETSIZE, histsize);
		history(hist, &he, H_SETUNIQUE, 1);
	}
}
Exemplo n.º 17
0
void Element::setUnreadBarCount(int count) {
	const auto changed = AddComponents(UnreadBar::Bit());
	const auto bar = Get<UnreadBar>();
	if (bar->freezed) {
		return;
	}
	bar->init(count);
	if (changed) {
		if (data()->mainView() == this) {
			recountAttachToPreviousInBlocks();
		}
		history()->owner().requestViewResize(this);
	} else {
		history()->owner().requestViewRepaint(this);
	}
}
Exemplo n.º 18
0
Arquivo: exec.c Projeto: knusbaum/Wily
/*
 * Child-side accounting for a recently started external process.
 *
 * 'fderr', 'fdout' are file descriptors for stdout and stderr
 * 'label' is the label of the window we started in.
 * 'cmd' is the command being executed
 * 'vin', if non-null, is the View to get stdin from.
 *
 * Does not return.
 * Don't use normal diag stuff -- we're a separate process.
 * After we've set up stderr, just fprintf(stderr,...)
 */
static void
ex_child(int fderr, int fdout, char *label, char *cmd, View *vin) {
	Path	dir;
	Path	path;
	
	childfds(fderr, fdout, vin);
	
	/* become process group leader */
	if(setsid()<0)
		perror("setsid");

	label2path(path, label);
	strcpy(dir,path);
	dirnametrunc(dir);
	
	/* Executing the command without being in the right directory
	 * would be _bad_.
	 */
	if(chdir(dir)){
		Path	buf;
		
		sprintf(buf, "chdir(%s)", dir);
		perror(buf);
		exit(1);
	}

	childenv(label, path);
	history(cmd);
	execl(shell, shell, "-c", cmd, 0);
	perror(shell);
	exit(1);
}
Exemplo n.º 19
0
void receive_history_result(const data_chunk& data,
    blockchain::fetch_handler_history handle_fetch)
{
    BITCOIN_ASSERT(data.size() >= 4);
    std::error_code ec;
    auto deserial = make_deserializer(data.begin(), data.end());
    if (!read_error_code(deserial, data.size(), ec))
        return;
    BITCOIN_ASSERT(deserial.iterator() == data.begin() + 4);
    size_t row_size = 36 + 4 + 8 + 36 + 4;
    if ((data.size() - 4) % row_size != 0)
    {
        log_error() << "Malformed response for *.fetch_history";
        return;
    }
    size_t number_rows = (data.size() - 4) / row_size;
    blockchain::history_list history(number_rows);
    for (size_t i = 0; i < history.size(); ++i)
    {
        blockchain::history_row& row = history[i];
        row.output.hash = deserial.read_hash();
        row.output.index = deserial.read_4_bytes();
        row.output_height = deserial.read_4_bytes();
        row.value = deserial.read_8_bytes();
        row.spend.hash = deserial.read_hash();
        row.spend.index = deserial.read_4_bytes();
        row.spend_height = deserial.read_4_bytes();
    }
    BITCOIN_ASSERT(deserial.iterator() == data.end());
    handle_fetch(ec, history);
}
Exemplo n.º 20
0
    virtual void _Reply_data(std::shared_ptr<protocol::Invoke> invoke) override final
    {
        if (invoke->has("_History_uid") == true)
        {
            // REGISTER THIS PROCESS ON HISTORY LIST
            std::shared_ptr<slave::InvokeHistory> history(new slave::InvokeHistory(invoke));
            progress_list_.insert({ history->getUID(), history });

            if (invoke->has("_Piece_first") == true)
            {
                // PARALLEL PROCESS
                size_t first = invoke->get("_Piece_first")->getValue<size_t>();
                size_t last = invoke->get("_Piece_last")->getValue<size_t>();

                invoke->erase(invoke->end() - 2, invoke->end());
                ((base::ParallelSystemArrayBase*)system_array_)->sendPieceData(invoke, first, last);
            }
            else if (invoke->has("_Process_name") == true)
            {
                // DISTRIBUTED PROCESS
                auto ds_system_array = (distributed::base::DistributedSystemArrayBase*)system_array_;

                // FIND THE MATCHED ROLE
                const std::string &process_name = invoke->get("_Process_name")->getValue<std::string>();
                if (ds_system_array->hasProcess(process_name) == false)
                    return;

                // SEND DATA VIA THE ROLE
                auto process = ds_system_array->getProcess(process_name);
                ((distributed::base::DistributedProcessBase*)(process.get()))->sendData(invoke, 1.0);
            }
        }
        else
            replyData(invoke);
    };
Exemplo n.º 21
0
int 
main(void)
{
  char* cmdLine;
  while(1){
    
    printf("JXYShell$ -");
    cmdLine = readline("> ");
    history(cmdLine);
    //scanf("%s", cmdLine);
    //printf("%s",cmdLine);
    //int num = piping(cmdLine);
    //printf("NUM:%d ", num);
    //parse(cmdLine);
    executeCommand(piping(cmdLine));
    //if (!strcmp(cmdLine, "exit")){
    //  exit(SUCCESS);
    //}
    /*if (cmdLine != NULL){
      history(cmdLine);
      executeCommand(cmdLine);
    }else{*/
      
    //}
  }
  return SUCCESS;
}
Exemplo n.º 22
0
void lessmore(char *command)
{
	int i,j,k,len=0,f=0;
	char *test,*a[100];
	if(strstr(command,">") && strstr(command,"<")) f=2;
	else if(strstr(command,">")!=NULL) f=1;
	test=strtok(command,"<>");
	while(test!=NULL) { a[len++]=test; test=strtok(NULL,"<>"); }
	a[len]=test;
	char *b[100],l=0;
	test=strtok(a[0]," \t");
	while(test!=NULL) 
	{
		b[l++]=test;
		test=strtok(NULL," \t");
	}
	b[l]=test;
	if(f==0||f==2) { a[1]=strtok(a[1]," "); FILE *in; in=freopen(a[1],"r",stdin); }
	if(f==1) { a[1]=strtok(a[1]," "); FILE *out; out=freopen(a[1],"w",stdout); }
	else if(f==2) { a[2]=strtok(a[2]," "); FILE *out; out=freopen(a[2],"w",stdout); }
	if(strstr(b[0],"hist")!=NULL) history(b[0]);
	else if(strstr(b[0],"pid")!=NULL) {
		if(l==1) pidpro();
		else if(l==2 && strstr(b[1],"all")!=NULL) pidall();
		else pidcurrent();
	}
	else exvp(b);
	exit(0);
}
Exemplo n.º 23
0
not_null<PeerData*> HistoryItem::senderOriginal() const {
	if (const auto forwarded = Get<HistoryMessageForwarded>()) {
		return forwarded->originalSender;
	}
	const auto peer = history()->peer;
	return (peer->isChannel() && !peer->isMegagroup()) ? peer : from();
}
Exemplo n.º 24
0
int sys_history(void) {
	int n;
	char * p;
	argptr(0, &p, 128);
	argint(1, &n);
	return history(p, n);
}
Exemplo n.º 25
0
static int acc_el_initialize(void)
{
    HistEvent ev;

    if (el != NULL)
        el_end(el);
    if (el_hist != NULL)
        history_end(el_hist);

    el = el_init("accedian", stdin, stdout, stderr);
    el_set(el, EL_PROMPT, cli_prompt);

    el_set(el, EL_EDITMODE, 1);
    el_set(el, EL_EDITOR, "emacs");
    el_hist = history_init();
    if (!el || !el_hist)
        return -1;

    /* setup history with 100 entries */
    history(el_hist, &ev, H_SETSIZE, 100);
    el_set(el, EL_HIST, history, el_hist);

    el_set(el, EL_ADDFN, "ed-complete", "Complete argument", cli_complete);

    /* Bind <tab> to command completion */
    el_set(el, EL_BIND, "^I", "ed-complete", NULL);
    #if 0   // Ticket #8152 - This corrupts show_rc passwords containing question marks
    /* Bind ? to command completion */
    el_set(el, EL_BIND, "?", "ed-complete", NULL);
    #endif
    /* Bind ^D to redisplay */
    el_set(el, EL_BIND, "^D", "ed-redisplay", NULL);

    return 0;
}
Exemplo n.º 26
0
void AXA_NORETURN
stop(int status)
{
	if (el_e != NULL) {
		if (el_history)
			history(el_history, &el_event, H_SAVE,
					history_savefile);
		history_end(el_history);
		el_end(el_e);
	}
	close_in_files();
	fflush(stderr);
	fflush(stdout);
	disconnect(false);
	if (nmsg_input != NULL)
		nmsg_input_close(&nmsg_input);
	if (nmsg_pres != NULL)
		nmsg_output_close(&nmsg_pres);	/* this closes stdout */
	out_close(false);

	axa_unload_fields();
	axa_unload_client_config();

	axa_io_cleanup();

	exit(status);
}
Exemplo n.º 27
0
void *
cmdinit(struct c**t *cmds, int ncmds)
{
	struct clitenv *env;
	HistEvent ev;

	if ((env = malloc(sizeof(*env))) == NULL)
		err(1, "Can't init cmd interpreter.");

	env->cmds = cmds;
	env->ncmds = ncmds;

	env->hist = history_init();
	history(env->hist, &ev, H_SETSIZE, 100);

	env->el = el_init(__progname, stdin, stdout, stderr);

	el_set(env->el, EL_EDITOR, "emacs");
	el_set(env->el, EL_PROMPT, prompt);
	el_set(env->el, EL_HIST, history, env->hist);
	el_set(env->el, EL_ADDFN, "complt", "complete", complt);
	el_set(env->el, EL_BIND, "\t", "complt");
	el_source(env->el, NULL);

	/* XXX - EL_SIGNAL ? */

	return env;
}
Exemplo n.º 28
0
int main(int argc, const char** argv) {
    const char* pname = argv[0];

    if (argc >= 2 && is_help(argv[1])) {
        return usage(pname, EXIT_SUCCESS);
    } else if (argc >= 3 && is_help(argv[2])) {
        return usage(pname, EXIT_SUCCESS);
    } else if (argc <= 2) {
        error("Not enough arguments");
        return usage(pname, EXIT_FAILURE);
    }

    const char* fname = argv[1];
    const char* action = argv[2];

    int sub_argc = argc - 3;
    const char** sub_argv = argv + 3;

    if (strncmp(action, "buy", 4) == 0) {
        return buy(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "sell", 5) == 0) {
        return sell(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "inventory", 10) == 0) {
        return inventory(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "state", 6) == 0) {
        return inventory(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "history", 8) == 0) {
        return history(pname, fname, sub_argc, sub_argv);
    } else {
        error("Unknown action %s", action);
        return usage(argv[0], EXIT_FAILURE);
    }
}
Exemplo n.º 29
0
/*  
    Prompt for input with the level of current nest (block nest depth)
 */
static char *readline(cchar *msg) 
{ 
    HistEvent   ev; 
    cchar       *str; 
    char        *result;
    ssize       len;
    int         count; 
 
    if (eh == NULL) { 
        eh = initEditLine();
    }
    prompt = msg;
    el_set(eh, EL_PROMPT, issuePrompt);
    el_set(eh, EL_SIGNAL, 1);
    str = el_gets(eh, &count); 
    if (str && count > 0) { 
        result = strdup(str); 
        len = slen(result);
        if (result[len - 1] == '\n') {
            result[len - 1] = '\0'; 
        }
        count = history(cmdHistory, &ev, H_ENTER, result); 
        return result; 
    }  
    return NULL; 
} 
Exemplo n.º 30
0
bool HistoryItem::suggestDeleteAllReport() const {
	auto channel = history()->peer->asChannel();
	if (!channel || !channel->canDeleteMessages()) {
		return false;
	}
	return !isPost() && !out() && from()->isUser() && toHistoryMessage();
}