Ejemplo n.º 1
0
/**
 * CFootyDoc::InsertChar
 * @brief ワイド文字一つを挿入します
 * @param wChar 挿入する文字
 * @return 描画範囲
 */
CFootyDoc::RedrawType CFootyDoc::InsertChar(wchar_t wChar)
{
	// 宣言
	LinePt pLine;
	size_t nPos;
	CUndoBuffer cUndo;
	CEditPosition cEditPosition = m_cCaretPos;
	RedrawType nRetRedraw = REDRAW_LINE;
	
	if ( IsReadOnly() ) return REDRAW_FAILED;
	
	// 選択文字列を削除、アンドゥ情報を格納
	if ( IsSelecting() )
	{
		DeleteSelected(&cUndo);
		cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE;
		nRetRedraw = REDRAW_ALL;
	}
	else if (m_bInsertMode || m_cCaretPos.GetPosition() == m_cCaretPos.GetLinePointer()->GetLineLength())
	{
		cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_INSERT;
	}
	else
	{
		// 上書きされるときは、アンドゥ情報を書き換える必要がある
		cUndo.m_cBeforeStart = cEditPosition;
		cEditPosition.MoveColumnForward(&m_lsLines,1);
		cUndo.m_cBeforeEnd = cEditPosition;
		cUndo.m_strBefore += m_cCaretPos.GetLinePointer()->GetLineData()
			[m_cCaretPos.GetPosition()];
		cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE;
	}
	cUndo.m_strAfter += wChar;
	
	// 文字を入れる
	pLine = m_cCaretPos.GetLinePointer();
	nPos = m_cCaretPos.GetPosition();
	if (m_bInsertMode || nPos == pLine->GetLineLength())
		pLine->m_strLineData.insert(nPos,1,wChar);
	else
		pLine->m_strLineData[nPos] = wChar;
	
	// 倫理行何行になるかチェック
	size_t nBeforeEthic = pLine->GetEthicLine();
	if (SetLineInfo(pLine, false/*改行を含むか by Tetr@pod*/))
		nRetRedraw = REDRAW_ALL;
	if (nBeforeEthic != pLine->GetEthicLine())
		nRetRedraw = REDRAW_ALL;

	// 桁を増加させる
	cUndo.m_cAfterStart = m_cCaretPos;
	m_cCaretPos.MoveColumnForward(&m_lsLines,1);
	cUndo.m_cAfterEnd = m_cCaretPos;

	// アンドゥ情報を挿入
	PushBackUndo(&cUndo);
	SendMoveCaretCallBack();
	return nRetRedraw;
}
Ejemplo n.º 2
0
BOOL ClipboardCut(void)
{
	if (!ClipboardCopy()) return (FALSE);
	DeleteSelected(17);
	GetXPos(&CurrCol);
	ShowEditCaret();
	return (TRUE);
}
Ejemplo n.º 3
0
void RegTreeCtrl::OnChar(wxKeyEvent& event)
{
    switch ( event.GetKeyCode() )
    {
    case WXK_DELETE:
        DeleteSelected();
        return;

    case WXK_RETURN:
        if ( event.AltDown() )
        {
            ShowProperties();

            return;
        }
    }

    event.Skip();
}
Ejemplo n.º 4
0
void CFVDownloads_Tasks::OnKeyDown(WORD wVK)
{
	switch (wVK)
	{
		case VK_DELETE:
			
			DeleteSelected (GetKeyState (VK_SHIFT) & 0x8000);
			break;

		case VK_RETURN:
			if (GetKeyState (VK_MENU) & 0x8000)
				ShowSelectedDldsProperties ();
			else
				CallSelectedDownload (TRUE);
			break;

		case VK_APPS:
			CalcCoordsForCurSel ();
			OnRClick ();
			break;
	}
}
Ejemplo n.º 5
0
void ReplaceSearched(HWND hDlg)
{	MODEENUM SaveMode = Mode;
	LONG	 Length;

	Magic	 = IsDlgButtonChecked(hDlg, IDC_MAGIC);
	HexInput = IsDlgButtonChecked(hDlg, IDC_HEXSEARCH);
	GetDlgItemTextW(hDlg, IDC_REPLACESTRING, CommandBuf, WSIZE(CommandBuf));
	hwndErrorParent = hDlg;			/*change parent of message box*/
	if ((Magic && !CheckParenPairs()) ||
		!BuildReplaceString(CommandBuf, &Length,
							&CurrPos, SelectCount,
							(WORD)(HexInput | 2 | (Magic ? 0 : 4)))) {
			hwndErrorParent = hwndMain;			/*change parent of message box*/
			return;
	}
	hwndErrorParent = hwndMain;			/*change parent of message box*/
	Mode = InsertMode;
	StartUndoSequence();
	if (SelectCount) DeleteSelected(19);
	HideEditCaret();
	{	LPREPLIST lpRep = &RepList;

		while (Length > (LONG)sizeof(lpRep->Buf)) {
			InsertBuffer((LPBYTE)lpRep->Buf, sizeof(lpRep->Buf), 2);
			Length -= sizeof(lpRep->Buf);
			if ((lpRep = lpRep->Next) == NULL) break;
		}
		if (Length && lpRep != NULL)
			InsertBuffer((LPBYTE)lpRep->Buf, Length, 2);
		FreeRepList();
	}
	GoBackAndChar(&CurrPos);
	Mode = SaveMode;
	FindValidPosition(&CurrPos, (WORD)(Mode==InsertMode));
	SendMessage(hDlg, DM_SETDEFID, IDOK, 0);
	SetFocus(GetDlgItem(hDlg, IDOK));
	EnableWindow(GetDlgItem(hDlg, IDC_REPLACE), FALSE);
}
Ejemplo n.º 6
0
/**
 * CFootyDoc::OnDelete
 * @brief Deleteキーが押されたときの処理を行います。
 * @return どのように再描画するのか
 */
CFootyDoc::RedrawType CFootyDoc::OnDelete()
{
	// 宣言
	CUndoBuffer cUndo;
	RedrawType nType;
	
	if ( IsReadOnly() ) return REDRAW_FAILED;
	
	// 選択しているかどうかで場合分け
	if (IsSelecting()){
		nType = DeleteSelected(&cUndo);
		PushBackUndo(&cUndo);
		return nType;
	}
	else{
		// 前に一つ移動してからBackSpaceという形にする
		CEditPosition cBackUp = m_cCaretPos;
		m_cCaretPos.MoveColumnForward(&m_lsLines,1);
		if (cBackUp != m_cCaretPos)	// 違う
			return OnBackSpace();
		else						// 末尾
			return REDRAW_NONE;
	}
}
Ejemplo n.º 7
0
void SaveMgrWindow::SaveListCtrl::OnDelete(wxCommandEvent& event)
{
	DeleteSelected();
}
Ejemplo n.º 8
0
BOOL ClipboardPaste(void)
{
	HGLOBAL  hMem = 0;
	LPSTR	 lpMem;
	UINT	 uFormat = CharSet == CS_OEM ? CF_OEMTEXT : CF_TEXT;
	LONG	 lSize;
	MODEENUM SaveMode;
	BOOL	 FreeConversionMemory = FALSE;

	if (IsViewOnly()) return(FALSE);

	/*prepare resources...*/
	if (!OpenClipboard(hwndMain)) {
		ErrorBox(MB_ICONEXCLAMATION, 302);
		return (FALSE);
	}

	/*first check for binary data containing null bytes...*/
	if (UtfEncoding != 16 && (hMem = GetClipboardData(uFormat)) != 0) {
		lSize = GlobalSize(hMem);
		if ((lpMem = GlobalLock(hMem)) != NULL) {
			LPSTR lp;
			LONG  lRemain;

			lp = _fmemchr(lpMem, '\0', (size_t)lSize);
			if (lp != NULL && (lp-lpMem+sizeof(BinaryPart)) <= (size_t)lSize
						   && lp[1]==BinaryFormat[0]
						   && _fmemchr(lp+1, '\0', lSize-(lp+1-lpMem)) != NULL
						   && _fmemcmp(lp+1, BinaryFormat, 10) == 0) {
				/*insert first part of null containing binary data...*/
				SaveMode = Mode;
				if (Mode != InsertMode && Mode != ReplaceMode) {
					StartUndoSequence();
					Mode = InsertMode;
				}
				if (SelectCount) DeleteSelected(17);
				else EnterDeleteForUndo(&CurrPos, 0, 1); /*force new undo elem*/
				Mode = SaveMode;
				HideEditCaret();
				if (*lpMem) InsertBuffer(lpMem, (UINT)(lp-lpMem), 0);
				lRemain = strtoul(lp+11, &lp, 10);
				if (*lp != ':') lSize = 0;
				else {
					if (lSize >= (lp - lpMem) + lRemain) lSize = lRemain;
					else lSize = 0;
					lpMem = lp + 1;
				}
				if (lSize) InsertBuffer(lpMem, (UINT)lSize, 1);
				GetXPos(&CurrCol);
				ShowEditCaret();

				/*clean up...*/
				GlobalUnlock(hMem);
				CloseClipboard();
				return (TRUE);
			}
			GlobalUnlock(hMem);
			hMem = 0;
		}
	}

	/*then, if running on Windows NT, try to get wide chars...*/
	if (!(GetVersion() & 0x80000000U) && CharSet != CS_EBCDIC) {
		UINT Cp;

		if (UtfEncoding == 8)
			 Cp = CP_UTF8;
		else if (CharSet == CS_ANSI)
			 Cp = AnsiCodePage;
		else Cp = OemCodePage;
		if (Cp) {
			HGLOBAL	hWideCharMem = GetClipboardData(CF_UNICODETEXT);
			WCHAR	*lpWideCharMem;

			if (hWideCharMem) {
				lSize		  = GlobalSize(hWideCharMem);
				lpWideCharMem = GlobalLock(hWideCharMem);
				if (lpWideCharMem != NULL) {
					INT	   nSizeRequired;
					PWCHAR wp;

					lSize >>= 1;
					wp = wmemchr(lpWideCharMem, '\0', lSize);
					if (wp != NULL) lSize = wp - lpWideCharMem;
					if (UtfEncoding == 16) {
						lSize <<= 1;
						if (UtfLsbFirst) {
							hMem  = hWideCharMem;
							lpMem = (LPSTR)lpWideCharMem;
						} else {
							hMem  = GlobalAlloc(GMEM_MOVEABLE, lSize);
							if (hMem) {
								lpMem = GlobalLock(hMem);
								if (lpMem != NULL) {
									INT i = 0;

									while ((i += 2) <= lSize) {
										lpMem[i-2] = *lpWideCharMem >> 8;
										lpMem[i-1] = *lpWideCharMem++ & 255;
									}
									FreeConversionMemory = TRUE;
								} else {
									GlobalFree(hMem);
									hMem = 0;
								}
							}
						}
					} else {
Ejemplo n.º 9
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jdlvFrame::jdlvFrame (const char *fileToLoad) : nextWorld(NULL),
  isChanged(false),
    eM(elModeView), genNo(0), curColor(0), speed(3), timerID(0)
{
  QFont fixedFont(jdlvFONTFACENAME, jdlvFONTSIZE);
        fixedFont.setStyleHint(QFont::TypeWriter);
  primeWorld = new_elMundoA();
  vista = new elVista (this, primeWorld); setCentralWidget(vista);
  vista->setMinimumSize(720, 480);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QToolBar *bottom = new permanentToolBar("ctrl", this);
  bottom->setFloatable(false);
  bottom->setMovable  (false);
  bottom->setIconSize(QSize(28,25));
  showTimeCB = new QAction(QIcon(":/time.png"), QString("time"), this);
  showInfoPB = new QAction(QIcon(":/info.png"), QString("info"), this);
  connect(showTimeCB, SIGNAL(triggered(bool)), this, SLOT(ToggleTime(bool)));
  connect(showInfoPB, SIGNAL(triggered()),     this, SLOT(ShowInfo()));
  bottom->addAction(showTimeCB);
  bottom->addAction(showInfoPB);         showInfoPB->setEnabled(false); //+
  bottom->addWidget(new QLabel(" "));
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QActionGroup *modeGroup = new QActionGroup(this);
  modeEdit = new QAction(QIcon(":/pen-in-box.png"),QString("Edit (X)"),  this);
  modeView = new QAction(QIcon(":/eye-half.png"),  QString("View (Z)"),  this);
  setColor = new QAction(QIcon(":/empty1.png"),    QString("color"),     this);
  connect(modeView, SIGNAL(triggered()), this, SLOT(SetModeView()));
  connect(modeEdit, SIGNAL(triggered()), this, SLOT(SetModeEdit()));
  connect(setColor, SIGNAL(triggered()), this, SLOT(PopupColorMenu()));
  showTimeCB->setCheckable(true);
  modeEdit  ->setCheckable(true); modeEdit->setShortcut(QKeySequence("X"));
  modeView  ->setCheckable(true); modeView->setShortcut(QKeySequence("Z"));
  modeView  ->setChecked  (true);
  modeGroup->addAction(modeView); bottom->addAction(modeView);
  modeGroup->addAction(modeEdit); bottom->addAction(modeEdit);
                                  bottom->addAction(setColor);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *file_menu = menuBar()->addMenu("File");
  openFile =  new QAction(QIcon(":/book.png"), QString("Open.."), this);
  reLoad = new QAction(QIcon(":/reload1.png"), QString("reload"), this);
  connect(openFile, SIGNAL(triggered()), this, SLOT(OpenFile()));
  connect(reLoad,   SIGNAL(triggered()), this, SLOT(DoReload()));
  file_menu->addAction(openFile);
  file_menu->addAction(reLoad);        reLoad->setEnabled(false);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *edit_menu = menuBar()->addMenu("Edit");
  deleteSelected = new QAction(QString("delete"), this);
  deleteSelected->setShortcut(QKeySequence("Del"));
  cropSelected   = new QAction(QString("crop"), this);
  pasteClipboard =
            new QAction(QIcon(":/win-paste.png"),   QString("paste"),    this);
  copyCLR = new QAction(QIcon(":/export-blue.png"), QString("copy"),     this);
  copyBnW = new QAction(QIcon(":/export-mono.png"), QString("copy b/w"), this);
  newWin = new QAction(QIcon(":/windows1.png"),   QString("new window"), this);
  bottom->addAction(pasteClipboard);     pasteClipboard->setEnabled(false); //+
  bottom->addAction(copyCLR); copyCLR->setShortcut(QKeySequence("Ctrl+C"));
  bottom->addAction(copyBnW);
  bottom->addAction(newWin);       newWin->setEnabled(false); //+
  connect(deleteSelected, SIGNAL(triggered()), this, SLOT(DeleteSelected()));
  connect(  cropSelected, SIGNAL(triggered()), this, SLOT(  CropSelected()));
  connect(pasteClipboard, SIGNAL(triggered()), this, SLOT(PasteClipboard()));
  connect(copyCLR, SIGNAL(triggered()), this, SLOT(CopyCLR()));
  connect(copyBnW, SIGNAL(triggered()), this, SLOT(CopyBnW()));
  connect(newWin, SIGNAL(triggered()), this, SLOT(NewWindow()));
  edit_menu->addAction(deleteSelected);
  edit_menu->addAction(  cropSelected); edit_menu->addSeparator();
  edit_menu->addAction(pasteClipboard); edit_menu->addAction(copyCLR);
                                        edit_menu->addAction(copyBnW);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  colorMenu = menuBar()->addMenu("Color");
#define ADD_colorMenu(ico,text,shortcut) \
  colorMenu->addAction(*ico,text)->setShortcut(QKeySequence(shortcut))
  ADD_colorMenu(enBlancoIco,            "blanco",     "B");
  ADD_colorMenu(enRojoIco,              "rojo (red)", "R");
  ADD_colorMenu(enCastanoIco, Utf8("castaño (brown)"),"C");
  ADD_colorMenu(enVerdeIco,          "verde (green)", "V");
  ADD_colorMenu(enAzulIco,             "azul (blue)", "A");
  colorMenu->addSeparator();
  colorMenu->addAction("random Bicolor")->setShortcut(QKeySequence("Ctrl+B"));
  colorMenu->addAction("random Recolor")->setShortcut(QKeySequence("Ctrl+R"));
  colorMenu->addAction("Un-color all")  ->setShortcut(QKeySequence("Ctrl+U"));
  connect(colorMenu, SIGNAL(triggered(QAction*)),
               this, SLOT(SelectColor(QAction*)));
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QLabel *magIcon = new QLabel; magIcon->setPixmap(QPixmap(":/zoom3.png"));
  magText = new QLabel(QString("+1"));
  magText->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  magText->setFont(fixedFont);
  magText->setMinimumSize(QSize(30,25));     bottom->addWidget(magText);
                                             bottom->addWidget(magIcon);
  fitView = new QAction(QIcon(":/full-size.png"), QString("fit"), this);
  connect(fitView, SIGNAL(triggered()), this, SLOT(DoFitView()));
  bottom->addAction(fitView);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *play_menu = menuBar()->addMenu("Play");
  playGen = new QLabel(QString("0"));
  playGen->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  playGen->setMinimumSize(QSize(66,25));
  prevGen =  new QAction(QIcon(":/step-back.png"),    QString("back"), this);
  nextGen =  new QAction(QIcon(":/go-forward.png") ,  QString("step"), this);
  playStop = new QAction(QIcon(":/fast-forward.png"), QString("go!"),  this);
  connect(prevGen,  SIGNAL(triggered()), this, SLOT(DoPrevGen()));
  connect(nextGen,  SIGNAL(triggered()), this, SLOT(DoNextGen()));
  connect(playStop, SIGNAL(triggered()), this, SLOT(DoPlayStop()));
  play_menu->addAction(nextGen);
  play_menu->addAction(playStop);
  play_menu->addAction(prevGen); prevGen->setEnabled(false);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  speedSlider = new QSlider(Qt::Horizontal, this);
  speedSlider->setMinimum(1); speedSlider->setValue(speed);
  speedSlider->setMaximum(4); speedSlider->setMaximumSize(50,22);
  speedSlider->setSingleStep(1);
  speedSlider->setTickInterval(1);
  speedSlider->setTickPosition(QSlider::TicksBelow);
  connect(speedSlider, SIGNAL(valueChanged(int)), this, SLOT(ChangeSpeed(int)));
  bottom->addWidget(playGen);
  bottom->addAction(nextGen);
  bottom->addWidget(speedSlider);
  bottom->addAction(playStop);
  addToolBar(Qt::BottomToolBarArea, bottom);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  if (fileToLoad) LoadTheWorld(fileToLoad);
  else                       SetWinTitle();
  show(); raise();
}
Ejemplo n.º 10
0
void CFVDownloads_Tasks::OnFvdldDelete() 
{
	DeleteSelected (FALSE);
}
Ejemplo n.º 11
0
/**
 * CFootyDoc::OnBackSpace
 * @brief BackSpaceキーが押されたときの処理を行います。
 * @return どのように再描画するのか
 * @note 適切な位置へキャレットが移動します。
 */
CFootyDoc::RedrawType CFootyDoc::OnBackSpace()
{
	// 宣言
	LinePt pLine = m_cCaretPos.GetLinePointer();
	size_t nPos = m_cCaretPos.GetPosition();
	CUndoBuffer cUndo;
	RedrawType nType;
	
	if ( IsReadOnly() ) return REDRAW_FAILED;
	
	// 場合分け
	if (IsSelecting())
	{
		nType = DeleteSelected(&cUndo);
		PushBackUndo(&cUndo);
		return nType;
	}
	else	// 選択していないとき
	{
		if (nPos != 0)			// 文字を削除
		{
			bool bIsSurrogatePair = CFootyLine::IsSurrogateTail(pLine->GetLineData()[nPos-1]);
			RedrawType nNeedRedraw = REDRAW_LINE;
			
			// アンドゥ情報を代入する
			cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_DELETE;
			if (bIsSurrogatePair)
				cUndo.m_strBefore = pLine->m_strLineData.substr(nPos-2,2);
			else	
				cUndo.m_strBefore = pLine->m_strLineData.substr(nPos-1,1);
			cUndo.m_cBeforeEnd = m_cCaretPos;
			
			// 文字列を削除する
			if (bIsSurrogatePair)
				pLine->m_strLineData.erase(nPos-2,2);
			else
				pLine->m_strLineData.erase(nPos-1,1);
			size_t nBeforeEthic = pLine->GetEthicLine();
			if (SetLineInfo(pLine, false/*改行を含むか by Tetr@pod*/))
				nNeedRedraw = REDRAW_ALL;
			if (nBeforeEthic != pLine->GetEthicLine())
				nNeedRedraw = REDRAW_ALL;
			
			// ポジションを移動して
			if (bIsSurrogatePair)
				m_cCaretPos.MoveColumnBackward(&m_lsLines,2);
			else
				m_cCaretPos.MoveColumnBackward(&m_lsLines,1);
			
			// アンドゥ情報を格納する
			cUndo.m_cBeforeStart = m_cCaretPos;
			PushBackUndo(&cUndo);
			SendMoveCaretCallBack();
			return nNeedRedraw;
		}
		else					// 改行を削除
		{
			if (pLine != m_lsLines.begin())
			{
				// 次の行ポインタ取得
				LinePt pPrevLine = pLine;
				pPrevLine--;

				// アンドゥ情報を代入しつつキャレット位置を移動する
				cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_DELETE;
				cUndo.m_strBefore = L"\r\n";
				cUndo.m_cBeforeEnd = m_cCaretPos;
				m_cCaretPos.MoveColumnBackward(&m_lsLines,1);
				cUndo.m_cBeforeStart = m_cCaretPos;
				PushBackUndo(&cUndo);

				// 行の結合
				pPrevLine->m_strLineData += pLine->GetLineData();

				// 現在の位置を削除する
				DeleteLine(pLine);

				// 情報を更新する
				LinePt pNextLine = pPrevLine;
				pNextLine++;      
				SetLineInfo(pPrevLine,pNextLine, false);  

				SendMoveCaretCallBack();
				return REDRAW_ALL;
			}
			else return REDRAW_NONE;
		}
	}
}
Ejemplo n.º 12
0
/**
 * @brief 現在のキャレット位置で改行処理を行います。
 * @param	bIndentMode [in] オートインデントを行うかどうか
 */
CFootyDoc::RedrawType CFootyDoc::InsertReturn( bool bIndentMode )
{
	// 宣言
	CUndoBuffer cUndo;
	CFootyLine cNewLine;
	LinePt pLine, pInsertPos;
	size_t nPos;
	
	if ( IsReadOnly() ) return REDRAW_FAILED;
	
	// 選択位置を削除します
	if (IsSelecting())
	{
		DeleteSelected(&cUndo);
		cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE;
	}
	else
	{
		cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_INSERT;
	}
	cUndo.m_cAfterStart = m_cCaretPos;
	
	// 改行を挿入する位置を取得します
	pLine = m_cCaretPos.GetLinePointer();
	nPos = m_cCaretPos.GetPosition();

	// オートインデントとして挿入できる文字数をカウントします
	size_t nIndentChars = 0;
	if ( bIndentMode )
	{
		nIndentChars = pLine->CalcAutoIndentPos( nPos );
	}

	// 挿入後、となるテキストを作成します
	cUndo.m_strAfter = L"\r\n";
	if  ( nIndentChars != 0 )
	{
		cUndo.m_strAfter.append( pLine->GetLineData(), nIndentChars );
	}

	// 行末で改行してないときは次の行に回します
	if (pLine->GetLineLength() != nPos)
	{
		if ( nIndentChars == 0 )
		{
			cNewLine.m_strLineData = &pLine->GetLineData()[nPos];
		}
		else
		{
			cNewLine.m_strLineData.append( pLine->GetLineData(), nIndentChars );
			cNewLine.m_strLineData += &pLine->GetLineData()[nPos];
		}
		pLine->m_strLineData.erase(nPos);
	}
	else if  ( nIndentChars != 0 )
	{
		cNewLine.m_strLineData.append( pLine->GetLineData(), nIndentChars );
	}

	// 次の行をリストに追加
	pInsertPos = pLine;
	pInsertPos++;
	pInsertPos = m_lsLines.insert( pInsertPos, cNewLine );
	SetLineInfo( pLine, pInsertPos, false/*改行を含むか by Tetr@pod*/ );

	// キャレット位置を移動させる
	m_cCaretPos.SetPosition( pInsertPos, nIndentChars );

	// 再度更新
	SetLineInfo( pLine, pInsertPos, false/*改行を含むか by Tetr@pod*/ );

	// アンドゥー情報を格納
	cUndo.m_cAfterEnd = m_cCaretPos;
	PushBackUndo(&cUndo);
	SendMoveCaretCallBack();
	return REDRAW_ALL;
}
Ejemplo n.º 13
0
/**
 * CFootyDoc::InsertString
 * @brief 現在のキャレット位置に文字を挿入します。
 * @param pString 挿入する文字列(NULL終端)
 * @param bRecUndo trueのときアンドゥを記録する
 * @param bOverwritable INSERTキーによる上書きチェックを有効にする
 * @param bMemLineMode 改行コードをこの文章のコードとして保存する
 */
CFootyDoc::RedrawType CFootyDoc::InsertString
		(const wchar_t *pString,bool bRecUndo,bool bOverwritable,bool bMemLineMode)
{
	FOOTY2_PRINTF( L"InsertString開始\n");
	// 宣言
	const wchar_t *pWork;			//!< 改行位置検索用
	std::wstring strRestLine;		//!< 挿入位置以降のデータ
	LinePt pLine,pBeginLine;
	size_t nNumLines = 0;
	size_t nPos;
	CUndoBuffer cUndo;

	// エラーチェック
	if ( !pString )return REDRAW_FAILED;
	if ( IsReadOnly() ) return REDRAW_FAILED;
	
	// 上書きの場合は
	if (bOverwritable && !m_bInsertMode && !IsSelecting())
	{
		// 長さを計測する
		size_t nStrLen = wcslen(pString);
		size_t nLineLeft = m_cCaretPos.GetLinePointer()->GetLineLength()
							- m_cCaretPos.GetPosition();
		// 選択処理
		SetSelectStart();
		m_cCaretPos.MoveColumnForward(&m_lsLines,min(nLineLeft,nStrLen));
		SetSelectEndNormal();
		// そして、再帰
		return InsertString(pString);
	}

	// 選択位置情報を削除してアンドゥ情報を代入
	if (bRecUndo)
	{
		if (IsSelecting())
		{
			DeleteSelected(&cUndo);
			cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE;
		}
		else cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_INSERT;
		cUndo.m_cAfterStart = m_cCaretPos;
		cUndo.m_strAfter = pString;
	}
	else DeleteSelected(NULL);
	
	// キャレットの位置を取得する
	pLine = m_cCaretPos.GetLinePointer();
	pBeginLine = pLine;
	nPos = m_cCaretPos.GetPosition();

	// 文字を走査していく
	for (pWork=pString;;pWork++)
	{
		if (*pWork == L'\r')
		{
			if (*(pWork+1) == L'\n')	// CRLF
			{
				ReturnLine(&pLine,&pString,pWork,
							nPos,&strRestLine,2,nNumLines==0);
				nNumLines++;
				pWork++;
				if (bMemLineMode)m_nLineMode = LM_CRLF;
				FOOTY2_PRINTF( L"InsertString CRLF発見\n");
			}
			else						// キャリッジリターンのみ
			{
				ReturnLine(&pLine,&pString,pWork,
							nPos,&strRestLine,1,nNumLines==0);
				nNumLines++;
				if (bMemLineMode)m_nLineMode = LM_CR;
				FOOTY2_PRINTF( L"InsertString CR発見\n");
			}
		}
		else if (*pWork == L'\n')		// ラインフィード
		{
			ReturnLine(&pLine,&pString,pWork,
						nPos,&strRestLine,1,nNumLines==0);
			nNumLines++;
			if (bMemLineMode)m_nLineMode = LM_LF;
			FOOTY2_PRINTF( L"InsertString LF発見\n");
		}
		else if (*pWork == L'\0')		// 終端文字
		{
			FOOTY2_PRINTF( L"InsertString走査終了\n");
			if (!nNumLines)				// 今までに改行が無かったとき
			{
				FOOTY2_PRINTF( L"InsertString改行なし\n");
				// その位置に全ての文字列を挿入する
				pLine->m_strLineData.insert(nPos,pString);
				FOOTY2_PRINTF( L"InsertString変更確定しそう\n");
				SetLineInfo(pBeginLine, false/*改行を含むか by Tetr@pod*/);
				FOOTY2_PRINTF( L"InsertString変更確定\n");
				// キャレット位置を移動させる
				m_cCaretPos.MoveColumnForward(&m_lsLines,(size_t)(pWork-pString));
			}
			else						// 改行があったとき
			{
				FOOTY2_PRINTF( L"InsertString改行あり\n");
				// バックアップ文字列を代入する
				pLine->m_strLineData = pString + strRestLine;
				// 変更を確定する
				FOOTY2_PRINTF( L"InsertString変更確定しそう\n");
				SetLineInfo(pBeginLine,pLine, true/*改行を含むか by Tetr@pod*/);
				FOOTY2_PRINTF( L"InsertString変更確定\n");
				// キャレット位置を移動させる
				m_cCaretPos.MoveRealNext(&m_lsLines,nNumLines);
				m_cCaretPos.MoveColumnForward(&m_lsLines,(size_t)(pWork-pString));
			}
			FOOTY2_PRINTF( L"InsertStringアンドゥ情報追加\n");
			// アンドゥ情報を挿入する
			if (bRecUndo)
			{
				cUndo.m_cAfterEnd = m_cCaretPos;
				PushBackUndo(&cUndo);
			}
			break;
		}
	}
	FOOTY2_PRINTF( L"InsertString終了間際\n");
	SendMoveCaretCallBack();
	FOOTY2_PRINTF( L"InsertString終了\n");
	return REDRAW_ALL;
}
void
ThemeInterfaceView::MessageReceived(BMessage *_msg)
{
	ThemeManager *tman;
	int32 value;
	int32 id;

_msg->PrintToStream();

	switch(_msg->what)
	{
		case B_REFS_RECEIVED:
			_msg->PrintToStream();
			break;

		case kMakeScreenshot:
			AddScreenshot();
			break;

		case kThemeSelected:
			ThemeSelected();
			break;

		case kApplyThemeBtn:
			ApplySelected();
			break;

		case kCreateThemeBtn:
		if (fNameText->IsHidden()) {
			float w = fNameText->Bounds().Width() + 10.0;
			fNameText->Show();
			fNameText->MakeFocus();
			fNewBtn->MoveBy(w, 0);
			fSaveBtn->MoveBy(w, 0);
			fDeleteBtn->MoveBy(w, 0);
			break;
		} else {
			float w = fNameText->Bounds().Width() + 10.0;
			fNameText->Hide();
			fNameText->MakeFocus(false);
			fNewBtn->MoveBy(-w, 0);
			fSaveBtn->MoveBy(-w, 0);
			fDeleteBtn->MoveBy(-w, 0);
		}
		/* FALLTHROUGH */

		case kReallyCreateTheme:
			CreateNew(fNameText->Text());
			break;

		case kSaveThemeBtn:
			SaveSelected();
			break;

		case kDeleteThemeBtn:
			DeleteSelected();
			break;
#if 0
		case kColorsChanged:
		case kGeneralChanged:
		case kFontsChanged:
		{
			BMessenger msgr (Parent());
			msgr.SendMessage(B_PREF_APP_ENABLE_REVERT);
			BMessage changes;
			if (_msg->FindMessage("changes", &changes) == B_OK)
			{
				update_ui_settings(changes);
			}
			break;
		}
#endif
		case B_PREF_APP_SET_DEFAULTS:
		{
			ApplyDefaults();
			break;
		}
		
		case B_PREF_APP_REVERT:
		{
			Revert();
			break;
		}
		
		case B_PREF_APP_ADDON_REF:
		{
			break;
		}

		case kThemeChanged:
		{
/*			BMessage data;
			BMessage names;
			get_ui_settings(&data, &names);
			fColorSelector->Update(data);
			fFontSelector->Refresh();
			fGeneralSelector->Refresh(data);
*/
			break;
		}

		case CB_APPLY:
			tman = GetThemeManager();
			_msg->PrintToStream();
			if (_msg->FindInt32("be:value", &value) < B_OK)
				value = false;
			if (_msg->FindInt32("addon", &id) < B_OK)
				break;

			if (id > -1) {
				tman->SetAddonFlags(id, (tman->AddonFlags(id) & ~Z_THEME_ADDON_DO_SET_ALL) | (value?Z_THEME_ADDON_DO_SET_ALL:0));
			} else {
				// apply globally
				int32 i;
				for (i = fAddonList->CountItems() - 1; i > 0; i--) {
					ThemeAddonItem *item = static_cast<ThemeAddonItem *>(fAddonList->ItemAt(i));
					item->ApplyBox()->SetValue(value);
					tman->SetAddonFlags(item->AddonId(), (tman->AddonFlags(item->AddonId()) & ~Z_THEME_ADDON_DO_SET_ALL) | (value?Z_THEME_ADDON_DO_SET_ALL:0));
				}
			}
			break;

		case CB_SAVE:
			tman = GetThemeManager();
			_msg->PrintToStream();
			if (_msg->FindInt32("be:value", &value) < B_OK)
				value = false;
			if (_msg->FindInt32("addon", &id) < B_OK)
				break;

			if (id > -1) {
				tman->SetAddonFlags(id, (tman->AddonFlags(id) & ~Z_THEME_ADDON_DO_RETRIEVE) | (value?Z_THEME_ADDON_DO_RETRIEVE:0));
			} else {
				// apply globally
				int32 i;
				for (i = fAddonList->CountItems() - 1; i > 0; i--) {
					ThemeAddonItem *item = static_cast<ThemeAddonItem *>(fAddonList->ItemAt(i));
					item->SaveBox()->SetValue(value);
					tman->SetAddonFlags(item->AddonId(), (tman->AddonFlags(item->AddonId()) & ~Z_THEME_ADDON_DO_RETRIEVE) | (value?Z_THEME_ADDON_DO_RETRIEVE:0));
				}
			}
			break;

		case BTN_PREFS:
			tman = GetThemeManager();
			if (_msg->FindInt32("addon", &id) < B_OK)
				break;
			tman->RunPreferencesPanel(id);
			break;

		case kHideSSPulse:
			break;
			
		case kShowSSPulse:
			break;
		
		case skOnlineThemes:
		{
			/*
			ZETA code:
			be_roster->Launch( "application/x-vnd.Mozilla-Firefox", 1,
				(char **)&skThemeURL);
			*/
			if (!be_roster->IsRunning(kHaikuDepotSig)) {
				be_roster->Launch(kHaikuDepotSig);
				snooze(1000000);
			}
			BMessenger msgr(kHaikuDepotSig);
			BMessage message(B_SET_PROPERTY);
			message.AddString("data", "_theme");
			message.AddSpecifier("Value");
			message.AddSpecifier("View", "search terms");
			message.AddSpecifier("Window", (int32)0);
			msgr.SendMessage(&message);
			break;
		}
		default:
		{
			BView::MessageReceived(_msg);
			break;
		}
	}
}
Ejemplo n.º 15
0
void Undo(WORD Flags)
	/* Flags:	0 =	called as vi-like undo:
	 *				undo of whole last operation,
	 *				a second undo reverts the undo operation,
	 *				entered as character 'u';
	 *			1 =	called as Windows-like undo:
	 *				undo last change at one position,
	 *				repeated undos go further back in history,
	 *				entered as <Alt+Bksp>, menu, or tool button;
	 *			2 = repeated vi-like undo ('.'):
	 *				can repeat both undo and redo;
	 *			4 = vi-like undo of whole line:
	 *				not yet implemented,
	 *				entered as character 'U';
	 */
{	LPUNDO	   lpUndo;
	BOOL	   fUndone = FALSE;
	ULONG	   StartSkip = (ULONG)-1;
	extern INT HexEditFirstNibble;

	if (Flags & 3) lpUndo = NextSequenceUndo;
	else {
		lpUndo = NextSequenceUndo = LastUndo;
		if (LastUndo != NULL) {
			LastUndo->Flags |= UD_START;
			if (LastUndo->Flags & UD_BYUNDO) {
				if (Redoing && LastUndo->UndoRef!=NULL)
					lpUndo = LastUndo->UndoRef;
				Redoing ^= TRUE^FALSE;
			} else Redoing = FALSE;
		}
	}
	if (lpUndo==NULL || (Redoing && !(lpUndo->Flags & UD_BYUNDO))) {
		Error(219);
		return;
	}
	if (IsViewOnly()) return;
	if (UtfEncoding == 16) {
		/*any undo ops must be double-byte, check before doing anything...*/
		LPUNDO lp = lpUndo;
		ULONG  Skip;

		while (lp != NULL) {
			if ((Skip = lpUndo->Pos) != (ULONG)-1) {
				if (lp->DelFill & 1 || lp->Inserted & 1) {
					ErrorBox(MB_ICONSTOP, 260);
					return;
				}
				if (StartSkip == (ULONG)-1) StartSkip = Skip;
				if (Flags & 1) break;
			}
			if (lp->Flags & UD_NEWOP && StartSkip != (ULONG)-1) break;
			lp = lp->Prev;
		}
		StartSkip = (ULONG)-1;
	}
	HideEditCaret();
	wsprintf(QueryString, "%s %s, used mem %lu",
			 Redoing ? "redoing" : "undoing",
			 lpUndo->Flags & UD_BYUNDO ? "undo" : "non-undo",
			 UndoMemUsed);
	QueryTime = GetTickCount();
	GlobalUndoFlags |= UD_BYUNDO;
	StartWithRemove = lpUndo->Flags & UD_START;
	StartUndoSequence();
	if (FirstUndo == NULL || (FirstUndo->Next == NULL && FirstUndo != lpUndo))
		lpUndo = NULL;
	StartWithRemove = TRUE;
	HexEditFirstNibble = -1;
	while (lpUndo != NULL) {
		POSITION Pos;
		ULONG	 Skip;

		if ((Skip = lpUndo->Pos) != (ULONG)-1) {
			if (StartSkip == (ULONG)-1) StartSkip = Skip;
			Pos.p = FirstPage;
			while (Skip >= Pos.p->Fill) {
				if (!Pos.p->Next) {
					if (Skip != Pos.p->Fill) {
						/*must not occur*/
						assert(Skip == Pos.p->Fill);	/*!?*/
						return;
					}
					break;
				}
				Skip -= Pos.p->Fill;
				Pos.p = Pos.p->Next;
			}
			if (SelectCount) {
				InvalidateArea(&SelectStart, SelectCount, 1);
				SelectCount = 0;
				UpdateWindow(hwndMain);
			}
			Pos.i = (UINT)Skip;
			Pos.f = 0;	/*TODO: check flags to be filled here*/
			if (lpUndo->Inserted) {
				SelectStart = Pos;
				SelectCount = lpUndo->Inserted;
				SelectBytePos = CountBytes(&SelectStart);
				DeleteSelected(3);
				fUndone   = TRUE;
				Indenting = FALSE;
			}
			if (lpUndo->DelFill) {
				LPSTR Buf;
				LONG  ByteCount = CountBytes(&Pos);

				if (lpUndo->Flags & UD_GLOBALMEM)
					 Buf = GlobalLock(lpUndo->DelMem);
				else Buf = (LPBYTE)lpUndo + sizeof(UNDO);
				if (Buf != NULL) {
					NewPosition(&Pos);
					InsertBuffer(Buf, lpUndo->DelFill, 0);
					fUndone = TRUE;
					if (lpUndo->Flags & UD_GLOBALMEM)
						GlobalUnlock(lpUndo->DelMem);
					/*reposition to current position...*/
					Pos.p = FirstPage;
					Pos.i = 0;
					Advance(&Pos, ByteCount);
					if (lpUndo->Flags & UD_SELECT && Flags & 1) {
						SelectStart = Pos;
						SelectCount = lpUndo->DelFill;
						SelectBytePos = CountBytes(&SelectStart);
						InvalidateArea(&SelectStart, SelectCount, 0);
						CheckClipboard();
					}
				} else ErrorBox(MB_ICONSTOP, 313);
			}
			if (Flags & 1) break;
		}
		if (lpUndo->Flags & UD_NEWOP && StartSkip != (ULONG)-1) break;
		lpUndo = lpUndo->Prev;
	}
	GlobalUndoFlags = 0;
	if (lpUndo != NULL) {
		if (lpUndo->Flags & UD_SAFE) {
			EnableToolButton(IDB_SAVE, FALSE);
			SetSafe(FALSE);
			GlobalUndoFlags = UD_SAFE;
		} else if (fUndone) SetUnsafe();
		LastUndo->UndoRef = NextSequenceUndo = lpUndo->Prev;
		#if 0
		//	if (NextSequenceUndo!=NULL && lpUndo->Flags & UD_BYUNDO
		//							   && !(NextSequenceUndo->Flags&UD_BYUNDO))
		//		NextSequenceUndo->Flags &= ~UD_START;
		#endif
	} else {
		if (fUndone) SetUnsafe();
		NextSequenceUndo = NULL;
	}
	if (Redoing) CheckForUndoneToRelease(FALSE);
	/*...undo information about redo and previous undo is not needed anymore
	 *   because the original undo information will be used instead.
	 */
	if (StartSkip != (ULONG)-1) {
		CurrPos.p = FirstPage;
		CurrPos.i = 0;
		Advance(&CurrPos, StartSkip);
		FindValidPosition(&CurrPos,
						  (WORD)(Mode==InsertMode || Mode==ReplaceMode));
		GetXPos(&CurrCol);
	}
	if (lpUndo==NULL || NextSequenceUndo==NULL)
		EnableToolButton(IDB_UNDO, FALSE);
	ShowEditCaret();
}
Ejemplo n.º 16
0
void CTorrents_Tasks::OnBtdldDelete() 
{
	DeleteSelected (FALSE);	
}