/**

Trims the sound data of a AIFF file for every high low combo in highlow
The size argument specifies how many high low combos are present in highlow

**/
File_Data trimAIFF(highlow_t* highlow, int size){

	File_Data data = processAIFF(stdout, stdin);
	if(!validateData(data)){
		fprintf(stderr, "Error occured in COMM chunk\n");
		exit(-1);
	}
	getSamplesAIFF(NULL, &data);

	int i;

	for(i = 0; i < size; i++){
		cut(&data, highlow[i].low, highlow[i].high);
	}

	writeHeaderAIFF(stdout, data);

	setupSoundAIFF(stdout, data);

	writeSamplesAIFF(stdout, data);
}
Esempio n. 2
0
int
viyankwholeline(UNUSED(char **args))
{
    int bol = findbol(), oldcs = zlecs;
    int n = zmult;

    startvichange(-1);
    if (n < 1)
	return 1;
    while(n--) {
     if (zlecs > zlell) {
	zlecs = oldcs;
	return 1;
     }
     zlecs = findeol() + 1;
    }
    vilinerange = 1;
    cut(bol, zlecs - bol - 1, CUT_YANK);
    zlecs = oldcs;
    return 0;
}
Esempio n. 3
0
int main() {
	lif::init();

	lif::Cutscene cut(sf::Vector2u(640, 480), {
		LAYER("bands.png", 0),
		LAYER("1_-1.png", 4),
		LAYER("1_0.png", 5),
		LAYER("1_0_5.png", 8),
		LAYER("1_1.png", 10),
		LAYER("1_2.png", 15),
		LAYER("1_3.png", 30),
	}, {
		SUB("It was a dark and gloomy night...", 3),
		SUB("And I felt the hatred of ten thousand years...", 3),
		SUB("Yet...", 2),
		SUB("My vengeance was just at its commencement...", 4),
		SUB("My enemies would soon suffer...", 2.5),
		SUB("Like I am.", 5),
	});

	sf::RenderWindow window(sf::VideoMode(640, 480), "test_cutscene");
	window.setFramerateLimit(120);
	lif::options.vsync = true;
	lif::options.showFPS = false;

	lif::WindowContext *cur_context = &cut;

	while (window.isOpen() && !lif::terminated) {
		cur_context->handleEvents(window);

		cur_context->update();

		window.clear();
		window.draw(*cur_context);
		lif::maybeShowFPS(window);
		window.display();
	}

	if (window.isOpen()) window.close();
}
Esempio n. 4
0
int main()
{
	freopen("t.in", "r", stdin);
	scanf("%d", &n_org);
	for(int i = 0; i < n_org; i ++)
		scanf("%lf", &org_pnt[i].x);
	for(int i = 0; i < n_org; i ++)
		scanf("%lf", &org_pnt[i].y);

	cur_pnt[0] = Point(- INF + 1, - INF);
	cur_pnt[1] = Point(- INF, INF + 1);
	cur_pnt[2] = Point(INF, INF + 1);
	cur_pnt[3] = Point(INF, - INF+ 1);
	n_cur = 4;
	for(int i = 0; i < n_org - 1; i ++)
	{
		Line l(org_pnt[i], org_pnt[i + 1]);
		cut(l);
	}

	int r = 0;
	for(int i = 1; i < n_cur; i ++)
		if(cur_pnt[i].x > cur_pnt[r].x)
			r = i;
	double ans = INF;
	for(int s = n_org - 2; s >= 0; s --)
	{	
		while(cur_pnt[r].x > org_pnt[s].x)
		{
			while(cur_pnt[r].x > org_pnt[s + 1].x)
				r = (r + 1) % n_cur;
			Line l(org_pnt[s], org_pnt[s + 1]);
			ans = MIN(ans, cur_pnt[r].y - (- l.a / l.b * cur_pnt[r].x - l.c / l.b));
			r = (r + 1) % n_cur;
		}
		Line l(cur_pnt[r], cur_pnt[(r + n_cur - 1) % n_cur]);
		ans = MIN(ans, (- l.a / l.b * org_pnt[s].x - l.c / l.b) - org_pnt[s].y);
	}
	printf("%.3lf\n", ans);
}
Esempio n. 5
0
CharacterList * CharacterSurface_LoadList()
{
	CharacterList * characters   = NULL;
	FILE          * listFile     = NULL;
	char          * buffer       = calloc(sizeof(char) * 255, sizeof(char));
	char          * orig_buffer  = buffer;
	char          * charFilename = NULL;
	char          * charName      = NULL;

	listFile = fopen(CHARACTER_LIST_FILE, "r");

	if(listFile == NULL)
	{
		fprintf(stderr, "Unable to open %s : ", CHARACTER_LIST_FILE);
		perror(NULL);
	}
	else
	{
		characters = CharacterList_new();
		while(fgets(buffer, 255, listFile) != NULL)
		{

			trim(&buffer);
			if(buffer[0] != '#' && buffer[0] != '\0')
			{
				charFilename = buffer;
				charName = cut(charFilename, '=');
				trim(&charFilename);
				trim(&charName);

				// Load and add the map to the list
				CharacterList_add(characters, charName, CharacterSurface_init(charFilename));
			}
		}
	}

	free(orig_buffer);
	fclose(listFile);
	return characters;
}
Esempio n. 6
0
void CtcForAll::contract(IntervalVector& x) {
	assert(x.size()==nb_var);

	IntervalVector  box(nb_var+_init.size());
	IntervalVector * sub;
	bool mdiam; int iter =0;
	box.put(0, x);

	std::list<IntervalVector> l;
	l.push_back(_init);
	std::pair<IntervalVector,IntervalVector> cut(_init,_init);

	while ((!l.empty())&&(iter<_max_iter)) {
		cut = _bsc.bisect(l.front());
		l.pop_front();
		sub = &(cut.first);
		for (int j=1;j<=2;j++) {
			if (j==2) sub = &(cut.second);

			for(int i=0; i< _init.size(); i++) {
				box[i+nb_var] = (*sub)[i].mid();
			}
			// it is enough to contract only with the middle, it is more precise and faster.
			try {
				_ctc.contract(box);
			} catch (EmptyBoxException& e) {
				x.set_empty(); throw e;
			}

			mdiam=true;
			for (int i=0;mdiam&&(i<_init.size()); i++) 	mdiam = mdiam&&((*sub)[i].diam()<= _prec);
			if (!mdiam) {
				l.push_back(*sub);
				iter++;
			}
		}
	}
	for(int i=0; i< nb_var; i++)  x[i] &= box[i];
	if (x.is_empty()) throw EmptyBoxException();
}
matrix<Flow> gusfield_all_pairs_min_cut(const Graph &g,
                                        const std::vector<size_t> &rev_edge,
                                        const std::vector<Flow> &capacity) {

  const size_t num_vertices = g.num_vertices();
  std::vector<size_t> parent(num_vertices);
  matrix<Flow> cut({num_vertices, num_vertices},
                   std::numeric_limits<Flow>::max());

  std::vector<bool> source_side;
  for (size_t i = 1; i != num_vertices; ++i) {
    const Flow min_cut =
        min_st_cut(g, i, parent[i], rev_edge, capacity, source_side);
    for (size_t j = i + 1; j != num_vertices; ++j)
      if (source_side[j] && parent[j] == parent[i])
        parent[j] = i;
    cut[{i, parent[i]}] = cut[{parent[i], i}] = min_cut;
    for (size_t j = 0; j != i; ++j)
      cut[{i, j}] = cut[{j, i}] = std::min(min_cut, cut[{parent[i], j}]);
  }
  return cut;
}
Esempio n. 8
0
void DictionaryTextEdit::keyPressEvent(QKeyEvent *e)
{
    if (e->modifiers() != Qt::ControlModifier)
    {
        QTextEdit::keyPressEvent(e);
        return;
    }
    if (e->key() == Qt::Key_C)    //CTRL+C
    {
        e->accept();
        if (copyAction->isEnabled())
            copy();
    }
    else if (e->key() == Qt::Key_X) //CTRL+X
    {
        e->accept();
        if (cutAction->isEnabled())
            cut();
    }
    else
        QTextEdit::keyPressEvent(e);
}
Esempio n. 9
0
void ChatBase::initMenuBar()
{
  // Icons: /opt/kde2/share/icons/hicolor/16x16/actions

  menuBar()->clear();

  KPopupMenu* fileMenu = new KPopupMenu(menuBar(), "FileMenu");
  fileMenu->insertItem(SmallIcon("filesave"), i18n("&Save (Formatted)"), this, SLOT(saveHTML()),
		       ALT+Key_S );
  fileMenu->insertItem(SmallIcon("filesave"), i18n("S&ave (Unformatted)"), this, SLOT(saveText()), ALT+Key_A );
  fileMenu->insertItem( i18n("&Close"), this, SLOT(quit()) );
  menuBar()->insertItem( i18n("&File"), fileMenu );
  
  KPopupMenu* editMenu = new KPopupMenu(menuBar(), "EditMenu");
  editMenu->insertItem(SmallIcon("editcopy"), i18n("&Copy"), this, SLOT(copy()), CTRL+Key_C );
  editMenu->insertItem(SmallIcon("editcut"), i18n("C&ut"), this, SLOT(cut()), CTRL+Key_X );
  editMenu->insertItem(SmallIcon("editpaste"), i18n("&Paste"), this, SLOT(paste()), CTRL+Key_V );
  menuBar()->insertItem( i18n("&Edit"), editMenu);


#if 0
	KPopupMenu* buddyMenu = new KPopupMenu(menuBar(), "BuddyMenu");
	buddyMenu->insertItem("&Profile",this,SLOT(profile()),CTRL+Key_P);
  menuBar()->insertItem("&Buddy", buddyMenu);

  KPopupMenu viewMenu = new KPopupMenu(menuBar, "ViewMenu");
  menuBar->insertItem("&View", viewMenu);

  KPopupMenu insertMenu = new KPopupMenu(menuBar, "InsertMenu");
  menuBar->insertItem("&Insert", insertMenu);

  KPopupMenu insertFaceMenu = new KPopupMenu(insertMenu, "FaceMenu");

  KPopupMenu helpMenu = new KPopupMenu(kmenuBar, "HelpMenu");
  menuBar->insertItem("&Help", helpMenu);
	
#endif

} // initMenuBar
Esempio n. 10
0
void MainWindow::initConnects()
{
    connect(ui->newFileAct, SIGNAL(triggered()), this, SLOT(newFileSlot()));
    connect(ui->openFileAct, SIGNAL(triggered()), this, SLOT(openFileSlot()));
    connect(ui->saveAct, SIGNAL(triggered()), this, SLOT(saveSlot()));
    connect(ui->saveasAct, SIGNAL(triggered()), this, SLOT(saveAsSlot()));
    connect(ui->exitAct, SIGNAL(triggered()), this, SLOT(close()));

    connect(ui->undoAct, SIGNAL(triggered()), ui->textEdit, SLOT(undo()));
    connect(ui->cutAct, SIGNAL(triggered()), ui->textEdit, SLOT(cut()));
    connect(ui->copyAct, SIGNAL(triggered()), ui->textEdit, SLOT(copy()));
    connect(ui->pasteAct, SIGNAL(triggered()), ui->textEdit, SLOT(paste()));

    connect(ui->fontAct, SIGNAL(triggered()), this, SLOT(selectFontSlot()));

    connect(ui->statuBarAct, SIGNAL(triggered()), this, SLOT(changStatuBarSlot()));

    connect(ui->aboutAct, SIGNAL(triggered()), this, SLOT(openAboutSlot()));
    connect(ui->aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->findAct, SIGNAL(triggered()), this, SLOT(openFindDialog()));
    connect(ui->dateAct, SIGNAL(triggered()), this, SLOT(newDateSlot()));
}
Esempio n. 11
0
// celociselne deleni 2 dlouhych cisel (stredoskolsky algoritmus)
// -- viz http://courses.cs.vt.edu/~cs1104/BuildingBlocks/divide.030.html
LNum operator/(LNum & dividend, LNum & divisor) {
  LNum quotient(1);
  quotient[0] = 0;
  to_normal_form(dividend);
  to_normal_form(divisor);

  // deleni nulou !!
  if (divisor.get_size() == 1 && divisor[0] == 0) {
    cout << "Division by zero!! Returning \"0\"!" << endl;
    return quotient;
  }

  // deleni mensiho cisla vetsim -> podil == 0
  if (dividend < divisor) {
    LNum oh(1);
    return oh;
  }

  // zarovnej delitel do leveho rohu delence
  int lock = dividend.get_size() - divisor.get_size();  // zarazka zpracovavane
                                                        // cifry v dividendu
  LNum portion = cut(dividend, lock, dividend.get_size()-1);

  do {
    if (!(portion<divisor)) {
      portion = portion - divisor;
      quotient.append(1);
    } else {
      quotient.append(0);
    }
    if (--lock >= 0) {
      portion.append(dividend[lock]);
    }
  } while (lock >= 0);

  to_normal_form(quotient);

  return quotient;
}
Esempio n. 12
0
rid *dcRSys::cmd(rid *r) {

	if(is_rid(r,"put")){
		// put rid data
		if(r->cr != NULL) put_rid(cur,r->cr);
		else printf("need more parameter");

		return cur;
	}

	if(is_rid(r,"ls")) {
		cout_rid(cur);
		return cur;
	}

	if(is_rid(r,"go")){
		if(r->cr != NULL) cur = go(cur, r->cr);
		else cur = go(cur, last);
		cur_path();
		return cur;
	}

	if(is_rid(r,"path")){
		cur_path();
		return cur;
	}


	if(is_rid(r,"cut")){
		if(r->cr != NULL) cur = cut(cur, r->cr);
	}




	return cur;
	//print_rid(cur);

}
Esempio n. 13
0
int
main (int argc, char **argv) {
  char *city;
  char *cities[] = {"bos", "ny", "la"};
  int box, store;
  int oneortwo[] = {2, 1};

  /* nd_debug = 1; */

  choose(city, 3, cities);
  mark();
  choose(store, 2, oneortwo);
  choose(box, 2, oneortwo);
  printf("(%s %d %d) ", city, store, box);
  if (coinp(city, store, box)) {
    cut();
    printf("C ");
  }
  fail();
  printf("\n");
  exit(0);
}
Esempio n. 14
0
char	*point(t_mysh *ptr)
{
  char	*path;
  int	last_slash;
  int	index;
  int	flag;

  last_slash = index = flag = 0;
  if (my_getenv("PWD", ptr) == 0)
    return (0);
  path = ptr->recup_getenv;
  while (path[index] != '\0')
    if (path[index++] == '/')
      last_slash++;
  index = 0;
  while (flag < last_slash)
    if (path[index++] == '/')
      flag++;
  if ((path = cut(path, index)) == 0)
    return (0);
  return (path);
}
Esempio n. 15
0
ILOUSERCUTCALLBACK4( CtCallback, IloNumVarArray, vars, int**, graph, int, num_cuts, int, max_deep ) {
	
	if( current_deep > max_deep ){
		//cout << "aa " << current_deep << endl;
		return;
	}
	
	IloNumArray vals(getEnv());
	getValues(vals, vars);
	IntegerFeasibilityArray feas( getEnv() );
	getFeasibilities( feas, vars );
	int old_win[vals.getSize()];
	memset(old_win, 0, sizeof(old_win));
	for(int n=0;  n<num_cuts; n++){
		static int cont=0;
		int cnt=0;
		for( int i = 0; i < 2; ++i ){
			IloRange cut( getEnv(), 0, 1 );
			if( getCut( vals, vars, CLQ2B, i, feas, cut, graph, old_win ) ){
				add(cut);
				cnt++;
				
			}
			else if( getCut( vals, vars, CLQ2A, i, feas, cut, graph, old_win ) ){
				cnt++;
				add(cut);
			}else{ //se nao encotrar algum corte, sai
				
								
			}
			cut.end();
		}
		if(n>1 && cnt==0)break;
	
			
	}
	feas.end();
	vals.end();
}
Esempio n. 16
0
	bool TextField::handleHotkeys(const KeyEvent &keyEvent )
	{
		if(!wantsHotkeys())
		{
			return false;
		}
		bool  isKeyDown = false;
		#ifdef __APPLE__
				isKeyDown = keyEvent.meta();
		#else
				isKeyDown = keyEvent.control();
		#endif


		if(isKeyDown && keyEvent.getKey() == KEY_A )
		{
			selectAll();
		}
		else if(isKeyDown && keyEvent.getKey() == KEY_C )
		{
			copy();
		}
		else if(isKeyDown && keyEvent.getKey() == KEY_X )
		{
			cut();
		}
		else if(isKeyDown && keyEvent.getKey() == KEY_V )
		{
			paste();
		}
		else
		{
			return false;
		}

		return true;


	}
Esempio n. 17
0
void DiagramWindow::createActions()
{
    exitAction = new QAction(tr("E&xit"), this);
    exitAction->setShortcut(tr("Ctrl+Q"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    addNodeAction = new QAction(QIcon(":/images/node.png"), tr("Add &Node"), this);
    addNodeAction->setShortcut(QKeySequence::New);
    connect(addNodeAction, SIGNAL(triggered()), this, SLOT(addNode()));

    addLinkAction = new QAction(QIcon(":/images/link.png"), tr("Add &Link"), this);
    addLinkAction->setShortcut(tr("Ctrl+L"));
    connect(addLinkAction, SIGNAL(triggered()), this, SLOT(addLink()));

    deleteAction = new QAction(QIcon(":/images/delete.png"), tr("&Delete"), this);
    deleteAction->setShortcut(tr("Del"));
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(del()));

    cutAction = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
    cutAction->setShortcut(QKeySequence::Cut);
    connect(cutAction, SIGNAL(triggered()), this, SLOT(cut()));

    copyAction = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
    copyAction->setShortcut(QKeySequence::Copy);
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));

    pasteAction = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
    pasteAction->setShortcut(QKeySequence::Paste);
    connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));

    bringToFrontAction = new QAction(QIcon(":/images/bringtofront.png"), tr("Bring to &Front"), this);
    connect(bringToFrontAction, SIGNAL(triggered()), this, SLOT(bringToFront()));

    sendToBackAction = new QAction(QIcon(":/images/sendtoback.png"), tr("&Send to Back"), this);
    connect(sendToBackAction, SIGNAL(triggered()), this, SLOT(sendToBack()));

    propertiesAction = new QAction(tr("P&roperties..."),this);
    connect(propertiesAction, SIGNAL(triggered()), this, SLOT(properties()));
}
Esempio n. 18
0
int main(int argc, char** argv) {
  scanf("%d%d", &N, &Q);
  for (int i=1; i<=N; i++)
    vt[i] = new (Splay::pmem++) Splay(i);
  while (Q--) {
    char cmd[105];
    int u, v;
    scanf("%s", cmd);
    if (cmd[1] == 'i') {
      scanf("%d%d", &u, &v);
      link(vt[v], vt[u]);
    } else if (cmd[0] == 'c') {
      scanf("%d", &v);
      cut(vt[1], vt[v]);
    } else {
      scanf("%d%d", &u, &v);
      int res=ask(vt[u], vt[v]);
      printf("%d\n", res);
    }
  }

  return 0;
}
Esempio n. 19
0
void MainWindow::connectActions()
{
    connect(ui->actionAbout_Qt,SIGNAL(triggered()),qApp,SLOT(aboutQt()));
    connect(ui->action_About,SIGNAL(triggered()),this,SLOT(about()));
    connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close()));
    connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(open()));
    connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save()));
    connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(saveAs()));
    connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newFile()));
    connect(ui->action_Go_to_Cell,SIGNAL(triggered()),this,SLOT(gotoCell()));

    connect(ui->action_Cut,SIGNAL(triggered()),spreadsheet,SLOT(cut()));
    connect(ui->action_Copy,SIGNAL(triggered()),spreadsheet,SLOT(copy()));
    connect(ui->action_Paste,SIGNAL(triggered()),spreadsheet,SLOT(paste()));
    connect(ui->action_Delete,SIGNAL(triggered()),spreadsheet,SLOT(del()));
    connect(ui->action_Row,SIGNAL(triggered()),spreadsheet,SLOT(selectCurrentRow()));
    connect(ui->actionColumn,SIGNAL(triggered()),spreadsheet,SLOT(selectCurrentColumn()));
    connect(ui->action_All,SIGNAL(triggered()),spreadsheet,SLOT(selectAll()));

    connect(ui->action_Recalculate,SIGNAL(triggered()),spreadsheet,SLOT(recalculate()));
    connect(ui->action_Show_Grid,SIGNAL(triggered(bool)),spreadsheet,SLOT(setShowGrid(bool)));

}
Esempio n. 20
0
void NodeBackDropPrivate::populateMenu()
{
    menu->clear();
    
    QAction* copyAction = new QAction("Copy",menu);
    copyAction->setShortcut(QKeySequence::Copy);
    QObject::connect(copyAction,SIGNAL(triggered()),_publicInterface,SLOT(copy()));
    menu->addAction(copyAction);
    
    QAction* cutAction = new QAction("Cut",menu);
    cutAction->setShortcut(QKeySequence::Cut);
    QObject::connect(cutAction,SIGNAL(triggered()),_publicInterface,SLOT(cut()));
    menu->addAction(cutAction);
    
    QAction* duplicateAction = new QAction("Duplicate",menu);
    duplicateAction->setShortcut(QKeySequence(Qt::AltModifier + Qt::Key_C));
    QObject::connect(duplicateAction,SIGNAL(triggered()),_publicInterface,SLOT(duplicate()));
    menu->addAction(duplicateAction);
    
    QAction* cloneAction = new QAction("Clone",menu);
    cloneAction->setShortcut(QKeySequence(Qt::AltModifier + Qt::Key_K));
    QObject::connect(cloneAction,SIGNAL(triggered()),_publicInterface,SLOT(clone()));
    cloneAction->setEnabled(!_publicInterface->isSlave());
    menu->addAction(cloneAction);
    
    QAction* decloneAction = new QAction("Declone",menu);
    decloneAction->setShortcut(QKeySequence(Qt::AltModifier + Qt::ShiftModifier + Qt::Key_K));
    QObject::connect(decloneAction,SIGNAL(triggered()),_publicInterface,SLOT(declone()));
    decloneAction->setEnabled(_publicInterface->isSlave());
    menu->addAction(decloneAction);
    
    
    QAction* deleteAction = new QAction("Delete",menu);
    QObject::connect(deleteAction,SIGNAL(triggered()),_publicInterface,SLOT(remove()));
    menu->addAction(deleteAction);

}
Esempio n. 21
0
/*
 * v_yank -- [buffer][count]y[count][motion]
 *	     [buffer][count]Y
 *	Yank text (or lines of text) into a cut buffer.
 *
 * !!!
 * Historic vi moved the cursor to the from MARK if it was before the current
 * cursor and on a different line, e.g., "yk" moves the cursor but "yj" and
 * "yl" do not.  Unfortunately, it's too late to change this now.  Matching
 * the historic semantics isn't easy.  The line number was always changed and
 * column movement was usually relative.  However, "y'a" moved the cursor to
 * the first non-blank of the line marked by a, while "y`a" moved the cursor
 * to the line and column marked by a.  Hopefully, the motion component code
 * got it right...   Unlike delete, we make no adjustments here.
 *
 * PUBLIC: int v_yank __P((SCR *, VICMD *));
 */
int
v_yank(SCR *sp, VICMD *vp)
{
	size_t len;

	if (cut(sp,
	    F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, &vp->m_start,
	    &vp->m_stop, F_ISSET(vp, VM_LMODE) ? CUT_LINEMODE : 0))
		return (1);
	sp->rptlines[L_YANKED] += (vp->m_stop.lno - vp->m_start.lno) + 1;

	/*
	 * One special correction, in case we've deleted the current line or
	 * character.  We check it here instead of checking in every command
	 * that can be a motion component.
	 */
	if (db_get(sp, vp->m_final.lno, DBG_FATAL, NULL, &len))
		return (1);

	/*
	 * !!!
	 * Cursor movements, other than those caused by a line mode command
	 * moving to another line, historically reset the relative position.
	 *
	 * This currently matches the check made in v_delete(), I'm hoping
	 * that they should be consistent...
	 */  
	if (!F_ISSET(vp, VM_LMODE)) {
		F_CLR(vp, VM_RCM_MASK);
		F_SET(vp, VM_RCM_SET);

		/* Make sure the set cursor position exists. */
		if (vp->m_final.cno >= len)
			vp->m_final.cno = len ? len - 1 : 0;
	}
	return (0);
}
Esempio n. 22
0
void TextEdit::keyPressEvent(QKeyEvent *e)
{
    if (((e->key() == Key_Enter) || (e->key() == Key_Return)))
    {
        //   in m_bCtrlMode:    enter      --> newLine
        //                      ctrl+enter --> sendMsg
        //   in !m_bCtrlMode:   enter      --> sendMsg
        //                      ctrl+enter --> newLine
        // the (bool) is required due to the bitmap
        if (m_bCtrlMode == (bool)(e->state() & ControlButton)){
            emit ctrlEnterPressed();
            return;
        }
    }
    if (!isReadOnly()){
        if ((e->state() == ShiftButton) && (e->key() == Key_Insert)){
            paste();
            return;
        }
        if ((e->state() == ControlButton) && (e->key() == Key_Delete)){
            cut();
            return;
        }
    }
#if (COMPAT_QT_VERSION >= 0x030000) && (COMPAT_QT_VERSION < 0x030100)
    // Workaround about autoformat feature in qt 3.0.x
    if ((e->text()[0] == '-') || (e->text()[0] == '*')){
        if (isOverwriteMode() && !hasSelectedText())
            moveCursor(MoveForward, true);
        insert( e->text(), TRUE, FALSE );
        return;
    }
#endif
    // Note: We no longer translate Enter to Ctrl-Enter since we need
    // to know about paragraph breaks now.
    TextShow::keyPressEvent(e);
}
Esempio n. 23
0
void SampleTCOView::contextMenuEvent( QContextMenuEvent * _cme )
{
	if( _cme->modifiers() )
	{
		return;
	}

	QMenu contextMenu( this );
	if( fixedTCOs() == false )
	{
		contextMenu.addAction( embed::getIconPixmap( "cancel" ),
					tr( "Delete (middle mousebutton)" ),
						this, SLOT( remove() ) );
		contextMenu.addSeparator();
		contextMenu.addAction( embed::getIconPixmap( "edit_cut" ),
					tr( "Cut" ), this, SLOT( cut() ) );
	}
	contextMenu.addAction( embed::getIconPixmap( "edit_copy" ),
					tr( "Copy" ), m_tco, SLOT( copy() ) );
	contextMenu.addAction( embed::getIconPixmap( "edit_paste" ),
					tr( "Paste" ), m_tco, SLOT( paste() ) );
	contextMenu.addSeparator();
	contextMenu.addAction( embed::getIconPixmap( "muted" ),
				tr( "Mute/unmute (<%1> + middle click)" ).arg(
					#ifdef LMMS_BUILD_APPLE
					"⌘"),
					#else
					"Ctrl"),
					#endif
						m_tco, SLOT( toggleMute() ) );
	/*contextMenu.addAction( embed::getIconPixmap( "record" ),
				tr( "Set/clear record" ),
						m_tco, SLOT( toggleRecord() ) );*/
	constructContextMenu( &contextMenu );

	contextMenu.exec( QCursor::pos() );
}
Esempio n. 24
0
int main() {

	FILE *rp = oku(FINAME);

	int i;
	char *s;
	char *words[MAXLINE];

	s = malloc(MAXLINE); // bellek al
	for (i = 0; fscanf(rp, "%s", s) != EOF; i++) {
		reverse(s);
		words[i] = cut(s, 3); // s'in ilk 3 hanesini kes donder .
	}
	free(s); // free'le .
	words[i] = NULL; // words'i kapa .

	FILE *wp = yaz(FONAME);

	for (i = 0; words[i] != NULL; i++) {
		fprintf(wp, "%s", words[i]);
		free(words[i]); // free'le
	}
	exit(EXIT_SUCCESS);
}
Esempio n. 25
0
void TextEdit::keyPressEvent(QKeyEvent *e)
{
    if (((e->key() == Key_Enter) || (e->key() == Key_Return))){
        if (!m_bCtrlMode || (e->state() & ControlButton)){
            emit ctrlEnterPressed();
            return;
        }
    }
    if (!isReadOnly()){
        if ((e->state() == ShiftButton) && (e->key() == Key_Insert)){
            paste();
            return;
        }
        if ((e->state() == ControlButton) && (e->key() == Key_Delete)){
            cut();
            return;
        }
    }
#if (QT_VERSION >= 300) && (QT_VERSION < 0x030100)
    // Workaround about autoformat feature in qt 3.0.x
    if ((e->text()[0] == '-') || (e->text()[0] == '*')){
        if (isOverwriteMode() && !hasSelectedText())
            moveCursor(MoveForward, true);
        insert( e->text(), TRUE, FALSE );
        return;
    }
#endif
#if QT_VERSION >= 300
    if ((e->key() == Key_Return) || (e->key() == Key_Enter)){
        QKeyEvent e1(QEvent::KeyPress, e->key(), e->ascii(), e->state() | ControlButton, e->text(), e->count());
        QTextEdit::keyPressEvent(&e1);
        return;
    }
#endif
    TextShow::keyPressEvent(e);
}
Esempio n. 26
0
bool Foam::geomCellLooper::cut
(
    const vector& refDir,
    const label cellI,
    const boolList& vertIsCut,
    const boolList& edgeIsCut,
    const scalarField& edgeWeight,

    labelList& loop,
    scalarField& loopWeights
) const
{
    // Cut through cell centre normal to refDir.
    return cut
    (
        plane(mesh().cellCentres()[cellI], refDir),
        cellI,
        vertIsCut,
        edgeIsCut,
        edgeWeight,
        loop,
        loopWeights
    );
}
void TestOfficeDiscoverStrategy::TestDiscoverExcelDocumentStatistics()
{
   MockDocumentStatisticsVisitor visitor;
   OfficeDiscoverStrategy cut(visitor, EXCEL_DOCSTATS);
   cut.DiscoverDocumentStatistics();

   assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatisticsBegin")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatisticsBegin] was not raised."));
   assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatistics")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatistics] was not raised."));   
   assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatisticsEnd")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatisticsEnd] was not raised."));   
  
   //Creation date=1996/10/15 01:33:28 AM - Local time = System time + 2
   SYSTEMTIME expectedDate;
   expectedDate.wYear = 1996;
   expectedDate.wMonth = 10;
   expectedDate.wDay = 14;
   expectedDate.wHour = 23;
   expectedDate.wMinute = 33;
   expectedDate.wSecond = 28;
   expectedDate.wMilliseconds = 0;
   assertEquals(GetDateTimeString(&expectedDate), visitor[_T("Creation date")]);

   //Last save time=2004/12/3 12:25:00 PM
   expectedDate.wYear = 2004;
   expectedDate.wMonth = 12;
   expectedDate.wDay = 3;
   expectedDate.wHour = 10;
   expectedDate.wMinute = 25;
   expectedDate.wSecond = 0;
   expectedDate.wMilliseconds = 0;
   assertEquals(GetDateTimeString(&expectedDate), visitor[_T("Last save time")]);

   assertEquals(_T("pair"), visitor[_T("Last author")]);
   assertEquals(_T(""), visitor[_T("Revision number")]);
   assertEquals(_T(""), visitor[_T("Last print date")]);
   assertEquals(_T(""), visitor[_T("Total editing time")]);
}
Esempio n. 28
0
int main()
{
	int num;
	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif
	scanf("%d",&num);
	for(int i=0;i<num;i++)
	{
		printf("Case %d:\n",i+1);
		int BOSS;
		int man;
		int time;
		scanf("%d",&BOSS);
		scanf("%d",&man);
		int *IQ=creat(man);
		read(IQ,man);
		scanf("%d",&time);
		for(int come=0;come<time;come++)
		{
			int a,b;
			scanf("%d%d",&a,&b);
			cut(BOSS,IQ,man,a-1,b-1);
		}
		int flag=0;
		for(int count=0;count<man;count++)
		{
			if(IQ[count]>=BOSS) flag--;
		}
		if(flag<0) printf("Sorry,Bomb\n");
		else printf("Congratulations,professor\n");
		free(IQ);
	}
	return 0;
}
Esempio n. 29
0
void MultiLineEdit::mousePressEvent(QMouseEvent *e)
{
#if COMPAT_QT_VERSION < 0x030000
    if (e->button() == RightButton) {
        QPopupMenu *popup = createPopupMenu();
        int r = popup->exec( e->globalPos() );
        delete popup;
#ifndef QT_NO_CLIPBOARD
        if ( r == IdCut)
            cut();
        else if ( r == IdCopy)
            copy();
        else if ( r == IdPaste)
            paste();
#endif
        else if ( r == IdClear)
            clear();
        else
            menuActivated(r);
        return;
    }
#endif
    QMultiLineEdit::mousePressEvent(e);
}
Esempio n. 30
0
void DevGUI::editorChanged()
{
	DevEditor * e = qobject_cast<DevEditor*>(Editor->currentWidget());

    if ( e ) {
		
		const QTextDocument *doc = e->document();
		
        disconnect(doc, SIGNAL(modificationChanged(bool)),
                   actionSave, SLOT(setEnabled(bool)));
        disconnect(doc, SIGNAL(modificationChanged(bool)),
                   this, SLOT(setWindowModified(bool)));
        disconnect(doc, SIGNAL(undoAvailable(bool)),
                   actionUndo, SLOT(setEnabled(bool)));
        disconnect(doc, SIGNAL(redoAvailable(bool)),
                   actionRedo, SLOT(setEnabled(bool)));

        disconnect(actionUndo, SIGNAL(triggered()), doc, SLOT(undo()));
        disconnect(actionRedo, SIGNAL(triggered()), doc, SLOT(redo()));

        disconnect(actionCut, SIGNAL(triggered()), e, SLOT(cut()));
        disconnect(actionCopy, SIGNAL(triggered()), e, SLOT(copy()));
        disconnect(actionPaste, SIGNAL(triggered()), e, SLOT(paste()));

        disconnect(e, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
        disconnect(e, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

    }

    e = qobject_cast<DevEditor*>(Editor->currentWidget());
    if (!e)
        return;
    
	const QTextDocument *doc = e->document();
	
    fontChanged(doc->defaultFont());

    connect(doc, SIGNAL(modificationChanged(bool)),
            actionSave, SLOT(setEnabled(bool)));
    connect(doc, SIGNAL(modificationChanged(bool)),
            this, SLOT(setWindowModified(bool)));
    connect(doc, SIGNAL(undoAvailable(bool)),
            actionUndo, SLOT(setEnabled(bool)));
    connect(doc, SIGNAL(redoAvailable(bool)),
            actionRedo, SLOT(setEnabled(bool)));

    setWindowModified(e->isModified());
    actionSave->setEnabled(doc->isModified());
    actionUndo->setEnabled(doc->isUndoAvailable());
    actionRedo->setEnabled(doc->isRedoAvailable());

    connect(actionUndo, SIGNAL(triggered()), doc, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), doc, SLOT(redo()));

    const bool selection = e->textCursor().hasSelection();
    actionCut->setEnabled(selection);
    actionCopy->setEnabled(selection);

    connect(actionCut, SIGNAL(triggered()), e, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), e, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), e, SLOT(paste()));

    connect(e, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(e, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
}