2005-11-22 12:26:26 +00:00
|
|
|
// Scintilla source code edit control
|
|
|
|
/** @file StyleContext.cxx
|
|
|
|
** Lexer infrastructure.
|
|
|
|
**/
|
|
|
|
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
|
|
|
// This file is in the public domain.
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2010-11-24 21:23:05 +00:00
|
|
|
#include <assert.h>
|
2014-07-04 03:06:17 +02:00
|
|
|
#include <ctype.h>
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2010-11-24 21:23:05 +00:00
|
|
|
#include "ILexer.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2010-11-24 21:23:05 +00:00
|
|
|
#include "LexAccessor.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "Accessor.h"
|
|
|
|
#include "StyleContext.h"
|
2016-10-16 22:37:40 +02:00
|
|
|
#include "CharacterSet.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-06-18 13:02:34 +00:00
|
|
|
#ifdef SCI_NAMESPACE
|
|
|
|
using namespace Scintilla;
|
|
|
|
#endif
|
|
|
|
|
2016-10-16 22:37:40 +02:00
|
|
|
bool StyleContext::MatchIgnoreCase(const char *s) {
|
|
|
|
if (MakeLowerCase(ch) != static_cast<unsigned char>(*s))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
if (MakeLowerCase(chNext) != static_cast<unsigned char>(*s))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
for (int n = 2; *s; n++) {
|
|
|
|
if (static_cast<unsigned char>(*s) !=
|
|
|
|
MakeLowerCase(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + n, 0))))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-20 18:37:11 +02:00
|
|
|
static void getRange(Sci_PositionU start,
|
|
|
|
Sci_PositionU end,
|
2010-11-24 21:23:05 +00:00
|
|
|
LexAccessor &styler,
|
2005-11-22 12:26:26 +00:00
|
|
|
char *s,
|
2015-09-20 18:37:11 +02:00
|
|
|
Sci_PositionU len) {
|
|
|
|
Sci_PositionU i = 0;
|
2005-11-22 12:26:26 +00:00
|
|
|
while ((i < end - start + 1) && (i < len-1)) {
|
|
|
|
s[i] = styler[start + i];
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
s[i] = '\0';
|
|
|
|
}
|
|
|
|
|
2015-09-20 18:37:11 +02:00
|
|
|
void StyleContext::GetCurrent(char *s, Sci_PositionU len) {
|
2005-11-22 12:26:26 +00:00
|
|
|
getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
|
|
|
|
}
|
|
|
|
|
2015-09-20 18:37:11 +02:00
|
|
|
static void getRangeLowered(Sci_PositionU start,
|
|
|
|
Sci_PositionU end,
|
2010-11-24 21:23:05 +00:00
|
|
|
LexAccessor &styler,
|
2005-11-22 12:26:26 +00:00
|
|
|
char *s,
|
2015-09-20 18:37:11 +02:00
|
|
|
Sci_PositionU len) {
|
|
|
|
Sci_PositionU i = 0;
|
2005-11-22 12:26:26 +00:00
|
|
|
while ((i < end - start + 1) && (i < len-1)) {
|
|
|
|
s[i] = static_cast<char>(tolower(styler[start + i]));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
s[i] = '\0';
|
|
|
|
}
|
|
|
|
|
2015-09-20 18:37:11 +02:00
|
|
|
void StyleContext::GetCurrentLowered(char *s, Sci_PositionU len) {
|
2005-11-22 12:26:26 +00:00
|
|
|
getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
|
|
|
|
}
|