Пример #1
0
int32
TrackerString::IFindLast(const char* string, int32 beforeOffset) const
{
	if (string == NULL)
		return -1;

	int32 length = Length();
	uint32 stringLength = strlen(string);

	// The following two checks are required to be compatible
	// with BString:
	if (length <= 0)
		return -1;

	if (stringLength == 0)
		return beforeOffset;

	int32 start = MIN(beforeOffset, length - static_cast<int32>(stringLength));
	int32 stop = 0;
	int32 position = -1;

	for (int32 i = start; i >= stop; i--) {
		if (tolower(string[0]) == tolower(ByteAt(i))) {
			// This check is to avoid mute str*cmp() calls. Performance.
			if (strncasecmp(string, String() + i, stringLength) == 0) {
				position = i;
				break;
			}
		}
	}

	return position;
}
Пример #2
0
bool TexView::CanEndLine(int32 offset)
{
	if(ByteAt(offset) == B_ENTER)
		return true;
	else
		return false;
}
Пример #3
0
int32
TrackerString::FindFirst(const char* string, int32 fromOffset) const
{
	if (string == NULL)
		return -1;

	int32 length = Length();
	uint32 stringLength = strlen(string);

	// The following two checks are required to be compatible
	// with BString:
	if (length <= 0)
		return -1;

	if (stringLength == 0)
		return fromOffset;

	int32 stop = length - static_cast<int32>(stringLength);
	int32 start = MAX(0, MIN(fromOffset, stop));
	int32 position = -1;

	for (int32 i = start; i <= stop; i++) {
		if (string[0] == ByteAt(i)) {
			// This check is to avoid mute str*cmp() calls. Performance.
			if (strncmp(string, String() + i, stringLength) == 0) {
				position = i;
				break;
			}
		}
	}

	return position;
}
Пример #4
0
int TexView::FindFirstOnLine(char c,int offset,int eol)
{
	for(int i=offset;i<eol;i++)
	{
		if(ByteAt(i) == c)
			return i;
	}
	return -1;
}
Пример #5
0
int TexView::IsMathMode(int offset,vector<BString>& v,bool IsStart)
{
	for(int i=0;i<v.size();i++)
	{
		//try all possibilities....
		if(ByteAt(offset) == v[i].ByteAt(0))
		{
			//should be fixed to incorporate sol -- maybe not!
			if(offset-1 >= 0/*!= sol*/ && ByteAt(offset-1) == '\\')
				return -1;
				
			int len = v[i].Length();
		
				bool IsOk=true;
				int j=1;
				while(IsOk && j < len)
				{
					IsOk = (ByteAt(offset+j) == v[i].ByteAt(j));
					j++;
				}
				if(IsOk == true)
				{					
					if(len > 2)
					{
						if(IsStart)
						return offset+j;
							else
						return offset;
					}
					else
					{
						if(IsStart)
							return offset;
						else
							return offset+j;
					}
					
				}	
		}
	}
	return -1;
}
Пример #6
0
void TexView::FillSolEol(vector<int>& s,vector<int>& e,int start,int finish)
{
	int i=start;
	int text_length = TextLength();
	for(i=start;i>=0;i--)
	{
		if(ByteAt(i) == '\n')
		{
			break;
		}
	}
	start=i+1;
	
	i = finish;	
	for(i=finish;i<text_length;i++)
	{
		if(ByteAt(i) == '\n')
		{
			break;
		}
	}
	finish=i;
	
	for(i=start;i<=finish;i++)
	{
		if(ByteAt(i) == '\n')
		{
			e.push_back(i);
		}
	}
	
	e.push_back(i);
	
	s.push_back(start);
	for(i=0;i<e.size()-1;i++)
	{
		s.push_back(e[i]+1);
	}		
}
Пример #7
0
int32 TexView::OffsetAtIndex(int32 index)
{
	//int text_length = TextLength();
	int i;
	int count = 0;
	int last=0;
	for(i=0;count < index;i++)
	{
		if(ByteAt(i) == '\n')
		{
			count++;
			last = i+1;
		}
	}
	return last;	
}
Пример #8
0
void InsertChar(INT Char) {
	INT space = CharSize(Char);

	if (IsViewOnly()) return;
	SetUnsafe();
	if (Mode != ReplaceMode || (HexEditMode ? CharAt(&CurrPos) == C_EOF
											: CharFlags(CharAt(&CurrPos)) & 1))
		Reserve(&CurrPos, space, 0);
	else {
		INT oldspace = CharSize(CharAt(&CurrPos));

		if (space != oldspace) {
			Reserve(&CurrPos, -oldspace, 0);
			Reserve(&CurrPos, space, 0);
		} else {
			EnterDeleteForUndo(&CurrPos, oldspace, 0);
			EnterInsertForUndo(&CurrPos, space);
		}
		ByteAt(&CurrPos);
	}
	++InsertCount;
	if (!SuppressMap) switch (CharSet) {
		case CS_EBCDIC:
			if ((unsigned)Char >= 0x100) Char = 0x1a;
			else Char = MapAnsiToEbcdic[Char];
			break;

		case CS_OEM:
			Char = UnicodeToOemChar(Char);
			break;
	}
	assert(CurrPos.p->PageBuf);
	if (space > 1) {
		POSITION Pos = CurrPos;

		UnsafePage(&CurrPos);
		if (Char == C_CRLF) {
			if (UtfEncoding == 16) {
				assert((Pos.i & 1) == 0 && Pos.i + 1 < Pos.p->Fill);
				if (UtfLsbFirst) {
					Pos.p->PageBuf[Pos.i]	= '\r';
					Pos.p->PageBuf[Pos.i+1]	= '\0';
					Advance(&Pos, 2);
					Pos.p->PageBuf[Pos.i]	= '\n';
					Pos.p->PageBuf[Pos.i+1]	= '\0';
				} else {
					Pos.p->PageBuf[Pos.i]	= '\0';
					Pos.p->PageBuf[Pos.i+1]	= '\r';
					Advance(&Pos, 2);
					Pos.p->PageBuf[Pos.i]	= '\0';
					Pos.p->PageBuf[Pos.i+1]	= '\n';
				}
				assert(Pos.i + 1 < Pos.p->Fill);
			} else {
				Pos.p->PageBuf[Pos.i] = '\r';
				Advance(&Pos, 1);
				Pos.p->PageBuf[Pos.i] = '\n';
			}
		} else if (UtfEncoding == 16) {
			assert(Pos.i + 1 < Pos.p->Fill);
			if (UtfLsbFirst) {
				Pos.p->PageBuf[Pos.i]	= Char;
				Pos.p->PageBuf[Pos.i+1]	= Char >> 8;
			} else {
Пример #9
0
void
FindTextView::KeyDown(const char* bytes, int32 numBytes)
{
	if (fMode == kHexMode) {
		// filter out invalid (for hex mode) characters
		if (numBytes > 1)
			return;

		switch (bytes[0]) {
			case B_RIGHT_ARROW:
			case B_LEFT_ARROW:
			case B_UP_ARROW:
			case B_DOWN_ARROW:
			case B_HOME:
			case B_END:
			case B_PAGE_UP:
			case B_PAGE_DOWN:
				break;

			case B_BACKSPACE:
			case B_DELETE:
			{
				int32 start, end;
				GetSelection(&start, &end);

				if (bytes[0] == B_BACKSPACE && --start < 0) {
					if (end == 0)
						return;
					start = 0;
				}

				if (ByteAt(start) == ' ')
					BTextView::KeyDown(bytes, numBytes);

				BTextView::KeyDown(bytes, numBytes);

				if (bytes[0] == B_BACKSPACE)
					GetSelection(&start, &end);

				_HexReformat(start, start);
				Select(start, start);
				return;
			}

			default:
			{
				if (!strchr("0123456789abcdefABCDEF", bytes[0]))
					return;

				// the original KeyDown() has severe cursor setting
				// problems with our InsertText().

				int32 start, end;
				GetSelection(&start, &end);
				InsertText(bytes, 1, start, NULL);
				return;
			}
		}
	}
	BTextView::KeyDown(bytes, numBytes);
}
Пример #10
0
BOOL CALLBACK SearchCallback(HWND hDlg, UINT uMsg, WPARAM wPar, LPARAM lPar)
{	extern BOOL SearchBoxPosition, HexEditTextSide;
	extern INT  SearchBoxX, SearchBoxY;
	static RECT DlgRect;
	static BOOL Enabled;
	static CHAR CloseString[10];

	PARAM_NOT_USED(lPar);
	switch (uMsg) {
		RECT r;

		case WM_INITDIALOG:
			GetWindowRect(hDlg, &DlgRect);
			GetWindowRect(GetDlgItem(hDlg, IDC_REPLACE), &r);
			SetWindowPos(hDlg, 0, SearchBoxX, SearchBoxY,
								  DlgRect.right - DlgRect.left,
								  r.top - DlgRect.top,
						 SearchBoxPosition ? SWP_NOZORDER
										   : SWP_NOZORDER | SWP_NOMOVE);
			SendMessage(hDlg, DM_REPOSITION, 0, 0);
			EnableWindow(GetDlgItem(hDlg, IDC_SHOWREPLACE), FALSE);
			if (HexInput != (HexEditMode && !HexEditTextSide)) {
				HexInput ^= TRUE;
				*SearchBuf = '\0';
			}
			if (SelectCount && (HexInput ? 3 : 1) * SelectCount
							   < WSIZE(SearchBuf)) {
				POSITION SelPos;
				INT		 i, c;
				PWSTR	 p = SearchBuf;

				SelPos = SelectStart;
				for (i=(INT)SelectCount; i; --i) {
					if (HexInput) {
						c = ByteAt(&SelPos);
						if (Advance(&SelPos, 1) != 1) break;
						if (UtfEncoding == 16 && i > 1) {
							if (UtfLsbFirst)
								c |= ByteAt(&SelPos) << 8;
							else c = (c << 8) | ByteAt(&SelPos);
							if (Advance(&SelPos, 1) != 1) break;
							--i;
						}
						p += _snwprintf(p, WSIZE(SearchBuf) - (p-SearchBuf),
										UtfEncoding == 16 ? L"%04x " : L"%02x ",
										c);
					} else {
						if ((c = CharAt(&SelPos)) == C_CRLF) c = '\r';
						else if (!UtfEncoding) c = CharSetToUnicode(c);
						if (UtfEncoding == 16) {
							if (i > 1) --i;
							if (Advance(&SelPos, 2) != 2) break;
						} else if (Advance(&SelPos, 1) != 1) break;
						*p++ = c;
					}
				}
				if (HexInput) --p;
				*p = '\0';
				if (*SearchBuf && !ViewOnlyFlag)
					EnableWindow(GetDlgItem(hDlg, IDC_SHOWREPLACE), TRUE);
			} else {
				PWSTR p;

				if ((p = ExtractIdentifier(NULL)) != NULL)
					wcsncpy(SearchBuf, p, WSIZE(SearchBuf));
			}
			Enabled = *SearchBuf!='\0';
			if (Enabled) {
				EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
				SetDlgItemTextW(hDlg, IDC_SEARCHSTRING, SearchBuf);
				SendMessage(hDlg, DM_SETDEFID, IDOK, 0L);
			} else {
				SendMessage(hDlg, DM_SETDEFID, IDCANCEL, 0L);
				EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
			}
			EnableWindow(GetDlgItem(hDlg, IDC_REPLACESTRING), FALSE);
			EnableWindow(GetDlgItem(hDlg, IDC_REPLACE),       FALSE);
			EnableWindow(GetDlgItem(hDlg, IDC_REPLACEALL),    FALSE);
			CheckDlgButton(hDlg, *SrchDispBuf=='?' ? IDC_BACKWARD : IDC_FORWARD,
								 TRUE);
			CheckDlgButton(hDlg, IDC_MATCHCASE,	!IgnoreCaseFlag);
			CheckDlgButton(hDlg, IDC_MAGIC,		Magic);
			CheckDlgButton(hDlg, IDC_HEXSEARCH, HexInput);
			CheckDlgButton(hDlg, IDC_WHOLEWORD,	WholeWord);
			CheckDlgButton(hDlg, IDC_WRAPSCAN,	WrapScanFlag);
			LOADSTRING(hInst, 909, CloseString, sizeof(CloseString));
			ReplaceOpen = FALSE;
			PostMessage(hDlg, WM_COMMAND, 4569, 0);	/*for Wine*/
			return (TRUE);

		case WM_COMMAND:
			switch (COMMAND) {
				case 4569:
					/*Disable/enable again for Wine...*/
					EnableWindow(GetDlgItem(hDlg, IDOK), Enabled);
					break;
				case IDOK:
					SearchOk(hDlg);
					break;
				case IDCANCEL:
					if (ReplacingAll) Interrupted = TRUE;
					PostMessage(hDlg, WM_CLOSE, 0, 0);
					break;
				case IDC_SEARCHSTRING:
					GetDlgItemTextW(hDlg, IDC_SEARCHSTRING, CommandBuf, 4);
					if (Enabled != (*CommandBuf != '\0')) {
						if (Enabled ^= TRUE) {
							EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
							SendMessage(hDlg, DM_SETDEFID, IDOK, 0L);
						} else {
							SendMessage(hDlg, DM_SETDEFID, IDCANCEL, 0L);
							EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
						}
						if (ReplaceOpen) {
						  EnableWindow(GetDlgItem(hDlg,IDC_REPLACE),   Enabled);
						  EnableWindow(GetDlgItem(hDlg,IDC_REPLACEALL),Enabled);
						}
					}
					break;
				case IDC_SHOWREPLACE:
					EnableWindow(GetDlgItem(hDlg, IDC_REPLACESTRING), TRUE);
					EnableWindow(GetDlgItem(hDlg, IDC_REPLACE), SelectCount!=0);
					EnableWindow(GetDlgItem(hDlg, IDC_REPLACEALL),	  TRUE);
					SetWindowPos(hDlg, 0,0,0, DlgRect.right-DlgRect.left,
											  DlgRect.bottom-DlgRect.top,
								 SWP_NOZORDER | SWP_NOMOVE);
					SendMessage(hDlg, DM_REPOSITION, 0, 0);
					SetFocus(GetDlgItem(hDlg, IDC_REPLACESTRING));
					SendMessage(hDlg, DM_SETDEFID, IDC_REPLACE, 0L);
					EnableWindow(GetDlgItem(hDlg, IDC_SHOWREPLACE),  FALSE);
					ReplaceOpen = TRUE;
					break;
				case IDC_REPLACE:
					ReplaceSearched(hDlg);
					SetDlgItemText(hDlg, IDCANCEL, CloseString);
					break;
				case IDC_REPLACEALL:
					SetupSearchString(hDlg, NULL);
					GlobalSubst(hDlg);
					SetDlgItemText(hDlg, IDCANCEL, CloseString);
			}
			return (TRUE);

		case WM_MOVE:
		case WM_CLOSE:
			SearchBoxPosition = TRUE;
			GetWindowRect(hDlg, &r);
			SearchBoxX = r.left;
			SearchBoxY = r.top;
			if (uMsg == WM_CLOSE) {
				DestroyWindow(hDlg);
				hwndSearch = NULL;
			}
			return (TRUE);
	}
	return (FALSE);
}
Пример #11
0
void WrappingTextView::KeyDown(const char *bytes, int32 numBytes) 
{ 
	if (IsEditable() && numBytes==1) {
		m_last_key_was_del = (bytes[0]==B_DELETE);
		switch( bytes[0]) {
			case B_RIGHT_ARROW: {
				// implement word-wise movement:
				int32 mods = Window()->CurrentMessage()->FindInt32("modifiers");
				if (mods & (B_LEFT_CONTROL_KEY | B_RIGHT_OPTION_KEY)) {
					int32 len=TextLength();
					int32 startPos, endPos;
					GetSelection( &startPos, &endPos);
					if (endPos==len)
						break;
					if (startPos==endPos && (mods & B_SHIFT_KEY))
						m_selection_start=B_RIGHT_ARROW;
					int32 wordStart, wordEnd;
					if (mods & B_SHIFT_KEY && m_selection_start==B_LEFT_ARROW) {
						do {
							FindWord( startPos, &wordStart, &wordEnd);
							if (wordEnd > wordStart+1)
								break;
							if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
								break;
						} while( ++startPos < len);
						Select( MIN(endPos, wordEnd), endPos);
					} else {
						do {
							FindWord( endPos, &wordStart, &wordEnd);
							if (wordEnd > wordStart+1)
								break;
							if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
								break;
						} while( ++endPos < len);
						if (mods & B_SHIFT_KEY) {
							Select( startPos, wordEnd);
						} else
							Select( wordEnd, wordEnd);
					}
					ScrollToSelection();
				} else
					inherited::KeyDown( bytes, numBytes);
				break;
			}
			case B_LEFT_ARROW: {
				// implement word-wise movement:
				int32 mods = Window()->CurrentMessage()->FindInt32("modifiers");
				if (mods & (B_LEFT_CONTROL_KEY | B_RIGHT_OPTION_KEY)) {
					int32 startPos, endPos;
					GetSelection( &startPos, &endPos);
					if (!startPos)
						break;
					if (startPos==endPos && (mods & B_SHIFT_KEY))
						m_selection_start=B_LEFT_ARROW;
					int32 wordStart, wordEnd;
					if (mods & B_SHIFT_KEY && m_selection_start==B_RIGHT_ARROW) {
						--endPos;
						do {
							FindWord( endPos, &wordStart, &wordEnd);
							if (wordEnd > wordStart+1)
								break;
							if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
								break;
						} while( --endPos > 0);
						Select( startPos, MAX( startPos, wordStart));
					} else {
						--startPos;
						do {
							FindWord( startPos, &wordStart, &wordEnd);
							if (wordEnd > wordStart+1)
								break;
							if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
								break;
						} while( --startPos > 0);
						if (mods & B_SHIFT_KEY)
							Select( wordStart, endPos);
						else
							Select( wordStart, wordStart);
					}
					ScrollToSelection();
				} else
					inherited::KeyDown( bytes, numBytes);
				break;
			}
			default:
				inherited::KeyDown( bytes, numBytes);
				break;
		}
	} else if ( numBytes == 1 ) {
		// in read-only mode, we use cursor-keys to move scrollbar, and
		// we remap HOME / END to the vertical scrollbar (not the horizontal,
		// which is default).
		switch( bytes[0]) {
			case B_PAGE_UP:
			case B_PAGE_DOWN:
			case B_UP_ARROW:
			case B_DOWN_ARROW:
			case B_HOME: 
			case B_END: {
				// move vertical scrollbar:
				float min, max, smallStep, bigStep, value;
				BScrollBar* bar = ScrollBar( B_VERTICAL);
				if (!bar) 	return;
				bar->GetRange( &min, &max);
				bar->GetSteps( &smallStep, &bigStep);
				value = bar->Value();
				if (bytes[0] == B_UP_ARROW) {
					value = MAX( value-smallStep, min);
				} else if (bytes[0] == B_DOWN_ARROW) {
					value = MIN( value+smallStep, max);
				} else if (bytes[0] == B_PAGE_UP) {
					value = MAX( value-bigStep, min);
				} else if (bytes[0] == B_PAGE_DOWN) {
					value = MIN( value+bigStep, max);
				} else if (bytes[0] == B_HOME) {
					value = min;
				} else if (bytes[0] == B_END) {
					value = max;
				}
				bar->SetValue( value);
				break;
			}
			default:
				BTextView::KeyDown( bytes, numBytes);
				break;
		}
	} else
		inherited::KeyDown( bytes, numBytes);
}
Пример #12
0
void TexView::ITwoColorPlateau(char c,int sol,int eol,rgb_color c1,vector<rgb_color>& colorVec)
{
		int IsPlateau = false;
		int plLength = 0;
		int plStart;
		int i;
		for(i=sol;i<eol;i++)
		{
			//start a plateau
			if(c == '\\' && !IsPlateau && ByteAt(i) == c)
			{
				plStart = i;
				plLength++;
				IsPlateau = true;
			}
			else if(c != '\\' && !IsPlateau && ByteAt(i) == c &&  i - 1 >= 0 && ByteAt(i-1) != '\\')
			{
				plStart = i;
				plLength++;
				IsPlateau = true;
			}
			else if(IsPlateau && ByteAt(i) == c && i - 1 >= 0 && ByteAt(i-1) == c)
			{
				plLength++; 			
			}
			else if(IsPlateau && ByteAt(i) != c && i - 1 >= 0 && ByteAt(i-1) == c)
			{
				
				if(plLength % 2 == 0)
				{	
						for(int k=plStart;k<plStart+plLength;k++)
						{	
							colorVec[k-sol] = c1;
						}
				}
				else
				{
					for(int k=plStart;k<plStart+plLength-1 && k < eol;k++)
					{
							colorVec[k-sol] = c1;
					}
					colorVec[plStart+plLength-sol] = prefs->fg_color;
				
					if(c == '\\' && isalpha(ByteAt(i)))
					{
						BString match="";
						
						int j=i;
						for(j=i;j < eol;j++)
						{
							if(isalpha(ByteAt(j)))
								match << (char)ByteAt(j);
							else
								break;
						}
						if(match.Length() > 0)
						{			
							if(Contains(green_matches,match))
							{
									for(int k=i-1;k<j;k++)
										colorVec[k-sol] = prefs->format_cmd_color;
							}
							else if(Contains(purple_matches,match))
							{
									for(int k=i-1;k<j;k++)
										colorVec[k-sol] = prefs->special_cmd_color;
							}
							else 
							{	for(int k=i-1;k<j;k++)
										colorVec[k-sol] = prefs->generic_cmd_color;
							}
						}
					}
					else
					{
							colorVec[plStart+plLength-1-sol] = prefs->fg_color;
							//if(plLength %2 == 0)
							colorVec[plStart+plLength-sol] = prefs->fg_color;
					}
					
				}				

				IsPlateau = false;
				plLength = 0;
			}
		}
		if(IsPlateau)
		{				
				if(plLength % 2 == 0)
				{	
						for(int k=plStart;k<plStart+plLength;k++)
						{	
							colorVec[k-sol] = c1;
						}
				}
				else
				{
					for(int k=plStart;k<plStart+plLength-1 && k < eol;k++)
					{
							colorVec[k-sol] = c1;
					}
					colorVec[plStart+plLength-sol] = prefs->fg_color;
					if(c == '\\' && isalpha(ByteAt(i)))
					{
						BString match="";
						
						int j=i;
						for(j=i;j < eol;j++)
						{
							if(isalpha(ByteAt(j)))
								match << (char)ByteAt(j);
							else
								break;
						}
						if(match.Length() > 0)
						{			
							if(Contains(green_matches,match))
							{
									for(int k=i-1;k<j;k++)
										colorVec[k-sol] = prefs->format_cmd_color;
							}
							else if(Contains(purple_matches,match))
							{
									for(int k=i-1;k<j;k++)
										colorVec[k-sol] = prefs->special_cmd_color;
							}
							else 
							{	for(int k=i-1;k<j;k++)
										colorVec[k-sol] = prefs->generic_cmd_color;
							}
						}
					}	
					else
					{
							colorVec[plStart+plLength-1-sol] = prefs->fg_color;
						//	if(plLength %2 == 0)
							colorVec[plStart+plLength-sol] = prefs->fg_color;
					}
					
				}	
				

				IsPlateau = false;
				plLength = 0;
			}
			
}
Пример #13
0
void TexView::ParseLine(int sol,int eol,vector<rgb_color>& colorVec)
{
		int i;
		int offset = sol;
		int pos;
		int text_length = TextLength();
		//Setup some defaults....
		TwoColorPlateau('\'',sol,eol,prefs->comma_color,colorVec);
		TwoColorPlateau('`',sol,eol,prefs->comma_color,colorVec);
		TwoColorPlateau('\\',sol,eol,prefs->punc_symbol_color,colorVec);

		for(i=sol;i<eol;i++)
		{
			if(ByteAt(i) == '[' || ByteAt(i) == ']')
			{
				if(i-1 >= 0 && ByteAt(i-1) == '\\')
				{
					colorVec[i-1] = prefs->punc_symbol_color;
				}
					
				colorVec[i] = prefs->punc_symbol_color;			
				
			}
			else if(ByteAt(i) == '&' || ByteAt(i) == '{' || ByteAt(i) == '}')//
			{
				if(i-1 >= 0 && ByteAt(i-1) == '\\')
				{
					colorVec[i-1] = prefs->punc_symbol_color;
				}
					
				colorVec[i] = prefs->punc_symbol_color;			
				
			}
			else if(ByteAt(i) == '$')
			{
				if(i-1 >= 0 && ByteAt(i-1) == '\\')
				{
					colorVec[i-1] = prefs->fg_color;
					colorVec[i] = prefs->fg_color;
				}
			}
			else if(ByteAt(i) == '\\' && i+1 < eol)
			{
				if(ByteAt(i+1) == '#')
				{	
					colorVec[i] = prefs->punc_symbol_color;
					colorVec[i+1] = prefs->punc_symbol_color;
				}else if(ByteAt(i+1) == '\'' || ByteAt(i+1) == '`')
				{
					colorVec[i] = prefs->fg_color;
					colorVec[i+1] = prefs->fg_color;
				}
			}			
		}
		offset = sol;
		
		while((pos = FindFirstOnLine('%',offset,eol))>= 0 && offset < eol)
		{			
			if(pos - 1 >= 0 && ByteAt(pos-1) == '\\')
			{
					colorVec[pos-1] = prefs->punc_symbol_color;
					colorVec[pos] = prefs->punc_symbol_color;
			}
			else 
			{
				for(i=pos;i<eol;i++)
					colorVec[i] = prefs->comment_color;
				break;
			}			
			offset= pos+1;
		}	
}
Пример #14
0
void TexView::IParseLine(int sol,int eol)
{
		int size = eol-sol+1;
		vector<rgb_color> colorVec(size,prefs->fg_color);
		
		for(int k=0;k<size;k++)
		{
			colorVec[k] = prefs->fg_color;
		}
	
		int i;
		int offset = sol;
		int pos;
		int text_length = TextLength();
		//Setup some defaults....
		ITwoColorPlateau('\'',sol,eol,prefs->comma_color,colorVec);
		ITwoColorPlateau('`',sol,eol,prefs->comma_color,colorVec);
		ITwoColorPlateau('\\',sol,eol,prefs->punc_symbol_color,colorVec);

		for(i=sol;i<eol;i++)
		{
			if(ByteAt(i) == '[' || ByteAt(i) == ']')
			{
				if(i-1 >= 0 && ByteAt(i-1) == '\\')
				{
					colorVec[i-1-sol] = prefs->punc_symbol_color;
				}
					
				colorVec[i-sol] = prefs->punc_symbol_color;			
				
			}
			else if(ByteAt(i) == '&' || ByteAt(i) == '{' || ByteAt(i) == '}')//
			{
				if(i-1 >= 0 && ByteAt(i-1) == '\\')
				{
					colorVec[i-1-sol] = prefs->punc_symbol_color;
				}
					
				colorVec[i-sol] = prefs->punc_symbol_color;			
				
			}
			else if(ByteAt(i) == '$')
			{
				if(i-1 >= 0 && ByteAt(i-1) == '\\')
				{
					colorVec[i-1-sol] = prefs->fg_color;
					colorVec[i-sol] = prefs->fg_color;
				}
			}
			else if(ByteAt(i) == '\\' && i+1 < eol)
			{
				if(ByteAt(i+1) == '#')
				{	
					colorVec[i-sol] = prefs->punc_symbol_color;
					colorVec[i+1-sol] = prefs->punc_symbol_color;
				}else if(ByteAt(i+1) == '\'' || ByteAt(i+1) == '`')
				{
					colorVec[i-sol] = prefs->fg_color;
					colorVec[i+1-sol] = prefs->fg_color;
				}
			}			
		}
		offset = sol;
		
		while((pos = FindFirstOnLine('%',offset,eol))>= 0 && offset < eol)
		{			
			if(pos - 1 >= 0 && ByteAt(pos-1) == '\\')
			{
				colorVec[pos-1-sol] = prefs->punc_symbol_color;
				colorVec[pos-sol] = prefs->punc_symbol_color;
			}
			else 
			{
				for(i=pos;i<eol;i++)
					colorVec[i-sol] = prefs->comment_color;
				break;
			}
			offset= pos+1;
		}	
		
		//START COLOURING***********************************
			
		BFont default_font(be_fixed_font);
		default_font.SetSize(prefs->FontSize);

		int plLength=0;
		int plStart=0;
		for(i=sol;i<eol;i++)
		{
			if(i == sol)
			{
				plLength = 1;
				plStart = i;
			}
			else if(colorVec[i-sol] != colorVec[i-sol-1])
			{
				//if(colorVec[i-sol-1] != old_colors[i-sol])
					SetFontAndColor(plStart,plStart+plLength,&default_font,B_FONT_ALL,&colorVec[i-sol-1]);		
				
				plLength = 1;
				plStart = i;
			}
			else
			{
				plLength++;
			}	
		}
				
		if(plLength > 0)
			SetFontAndColor(plStart,plStart+plLength,&default_font,B_FONT_ALL,&colorVec[i-sol-1]);	
}
Пример #15
0
void TexView::ShiftLeft()
{
	int32 start,finish;
	GetSelection(&start,&finish);
	vector<int> sols;
	vector<int> eols;
	FillSolEol(sols,eols,0,TextLength()-1);//start,finish);
	int32 startline=-1;
	int32 endline=-1;
	//int TotalLines = CountLines();
	for(int i=0;i<sols.size();i++)
	{
		if(start >= sols[i] && start <= eols[i])
			startline = i;
		if(finish > sols[i] && finish <= eols[i])
			endline = i;
		else if(finish >= sols[i] && finish <= eols[i])
		{	
			endline = i-1;
			if(start == sols[i])
				endline++;
		}
		if(startline >= 0 && endline >= 0)
			break;
	}
	if(startline < 0 || endline < 0)
		return;
	
	//Select(0,0);//,start);
	//Highlight(sols[startline],eols[endline]);
	IsShifting = true;
	Select(sols[startline],sols[startline]);
	int tab_width=3;
	int offset_total=0;
	int first_offset=0;
	bool GotFirstOffset=false;
	for(int i=startline;i<=endline;i++)
	{
	//	sols[i]-= first_offset;
	//	eols[i]-= first_offset;
		int sol = sols[i]-offset_total;
		int eol = eols[i]-offset_total;
		if(//sol+2 < eol && 
		ByteAt(sol) == ' ' && ByteAt(sol+1) == ' ' && ByteAt(sol+2) == ' ')
		{
			Delete(sol,sol+3);
			offset_total+=3;
			//if(!GotFirstOffset)
			///{
			//	GotFirstOffset = true;
				first_offset=3;
			//}
			//if(startline == endline)
			//	Select(sol,eol-2);
		}
		else if(//sol+1 < eol && 
		ByteAt(sol) == ' ' && ByteAt(sol+1) == ' ')
		{
			Delete(sol,sol+2);
			offset_total+=2;
			//if(!GotFirstOffset)
			//{
			//	GotFirstOffset = true;
				first_offset=2;
			//}
			//if(startline == endline)
			//	Select(sol,eol-1);
		}  
		else if(//sol < eol && 
		ByteAt(sol) == ' ')
		{
			Delete(sol,sol+1);
			offset_total+=1;
			//if(!GotFirstOffset)
			//{
			//	GotFirstOffset = true;
				first_offset=1;
			//}
			//if(startline == endline)
			//	Select(sol,eol);
		}
		else if(//sol < eol && 
		ByteAt(sol) == '\t')
		{
			Delete(sol,sol+1);
			offset_total+=1;
			//if(!GotFirstOffset)
			//{
			//	GotFirstOffset = true;
				first_offset=1;
			//}
			//if(startline == endline)
			//	Select(sol,eol);
		}
		
		
		
	}
	//if(startline != endline)
		Select(sols[startline],eols[endline]-offset_total+1);
	IsShifting = false;
}