char * strchrmax(const char * s, int c, int max)
{
- char * result = null;
int i;
char ch;
for(i = 0; i < max && (ch = s[i]); i++)
if(ch == c)
- return s + i;
+ return (char *)s + i;
return null;
}
int length;
EditBox editBox;
public:
- property char * text
+ property const char * text
{
set
{
public enum EditBoxFindResult { notFound, found, wrapped };
-static char * keyWords1[] =
+static const char * keyWords1[] =
{
// C
"return","break","continue","default","switch","case","if","else","for","while", "do","long","short",
null
};
-static char * keyWords2[] =
+static const char * keyWords2[] =
{
- "defined", "warning", null
+ "defined", "warning",
+ "include", "pragma", "elif", "ifdef", "ifndef", "endif", "undef", "line",
+ null
};
-static char ** keyWords[] = { keyWords1, keyWords2 };
+static const char ** keyWords[] = { keyWords1, keyWords2 };
#define NUM_KEYWORD_GROUPS (sizeof(keyWords) / sizeof(char **))
//static int * keyLen[NUM_KEYWORD_GROUPS];
static int keyLen[NUM_KEYWORD_GROUPS][sizeof(keyWords1)];
property EditLine firstLine { get { return lines.first; } }; // Change these to a List<EditLine>... (this.lines[10].text)
property EditLine lastLine { get { return lines.last; } };
property EditLine line { get { return this.line; } }; // TODO: Add Set this.line = this.lines[10]
- property char * contents
+ property const char * contents
{
property_category $"Data"
set
return null;
}
- void SetLineText(char * text)
+ void SetLineText(const char * text)
{
if(this)
{
bool modified;
- void (* FontExtent)(Display display, Font font, char * text, int len, int * width, int * height);
+ void (* FontExtent)(Display display, Font font, const char * text, int len, int * width, int * height);
Color backColor;
bool rightButtonDown;
void NotifyDestroyed(Window window, DialogResult result)
{
ReplaceDialog dialog = (ReplaceDialog)window;
- char * replace = dialog.replaceString;
+ const char * replace = dialog.replaceString;
if(replace)
strcpy(replaceString, replace);
strcpy(searchString, dialog.searchString);
FontExtent = Display::FontExtent;
font = fontObject;
- lines.offset = (uint)&((EditLine)0).prev;
+ lines.offset = (uint)(uintptr)&((EditLine)0).prev;
style = EditBoxBits { hScroll = true };
}
}
- int CheckColors(EditLine line, int wc, bool selection, int selX, int editX, bool *selected,
- Color selectionForeground, Color selectionBackground, Color textColor, Color *foreground, Color *background, bool *opacity, bool *overwrite)
+ bool CheckColors(EditLine line, int wc, bool selection, int selX, int editX, bool *selected,
+ Color selectionForeground, Color selectionBackground, Color textColor, Color *foreground, Color *background, bool *opacity, int *overwrite)
{
bool flush = false;
if((style.stuckCaret && wc == line.count && !line.next) ||
(!mouseMove && line == this.line && wc == editX))
{
- *overwrite = true;
+ *overwrite = 1;
flush = true;
}
}
bool opacity;
// Overwrite Caret Stuff
- bool overWrite = false;
- int overWriteX, overWriteY;
- byte overWriteCh;
+ int overWrite = 0;
+ int overWriteX = 0, overWriteY = 0;
+ char overWriteCh;
// ****** SYNTAX STATES ******
bool inMultiLineComment = style.inMultiLineComment;
}
else if(x < box.right && !inQuotes && !inString && !inMultiLineComment && !inSingleLineComment && (isdigit(word[0]) || (word[0] == '.' && isdigit(word[1]))))
{
- char * dot = word[wordLen] == '.' ? word + wordLen : null;
+ char * dot = word[wordLen] == '.' ? word + wordLen : (word[0] == '.' && (word == line.buffer || word[-1] == '-' || isspace(word[-1])) ? word : null);
bool isReal = dot != null;
char * s = null;
if(dot)
if(firstWord)
{
inPrep = true;
- newTextColor = colorScheme.preprocessorColor;
+ newTextColor = wordLen == 1 ? colorScheme.keywordColors[1] : colorScheme.preprocessorColor;
}
}
if(x < box.right && !inQuotes && !inString && !inMultiLineComment && !inSingleLineComment)
{
for(g = 0; g < ((inPrep && word[0] != '#') ? 2 : 1); g++)
{
- char ** keys = keyWords[g];
+ const char ** keys = keyWords[g];
int * len = keyLen[g];
for(ccc = 0; keys[ccc]; ccc++)
{
{
flush = CheckColors(line, wc, selection, selX, editX, &selected, selectionForeground,
selectionBackground, textColor, &foreground, &background, &opacity, &overWrite);
- if(overWrite == true)
+ if(overWrite == 1)
{
overWriteCh = (wc < line.count) ? line.buffer[wc] : ' ';
if(overWriteCh == '\t') overWriteCh = ' ';
flagTrailingSpace = numSpaces && trailingSpace && style.syntax && start + bufferLen == line.count && line != this.line;
if(flagTrailingSpace) surface.SetBackground(red);
FlushBuffer(surface, line, wc, &renderStart, &x, y, numSpaces, flagTrailingSpace, box);
- if(overWrite == true)
+ if(overWrite == 1)
{
overWriteX = x;
overWriteY = y;
if(CheckColors(line, c, selection, selX, editX, &selected, selectionForeground,
selectionBackground, textColor, &foreground, &background, &opacity, &overWrite))
{
- if(overWrite == true)
+ if(overWrite == 1)
{
overWriteX = x;
overWriteY = y;
void ComputeLength(EditLine line)
{
int c;
- int tabOccur = 0;
- int tabWidth;
int x = 0;
for(c = 0; c < line.count; )
return false;
}
- bool AddToLine(char * stringLine, int count, bool LFComing, int * addedSpacesPtr, int * addedTabsPtr)
+ bool AddToLine(const char * stringLine, int count, bool LFComing, int * addedSpacesPtr, int * addedTabsPtr)
{
bool hadComment = false;
// Add the line here
{
int w;
int numBytes = 1;
- char * string;
+ const char * string;
if(c < Min(this.x, line.count))
string = line.buffer + c;
else if(c < endX)
// Returns true if it needs scrolling
bool FindMouse(int px, int py, int * tx, int * ty, EditLine * tline, bool half)
{
- int w;
int c;
- int x, y;
+ int y;
EditLine line;
bool needHScroll = false;
while(true)
{
int start = c;
- int numBytes = 1;
int len = 1;
int w;
if(c < Min(max, line.count))
}
/*
- bool SaveFile(char * fileName)
+ bool SaveFile(const char * fileName)
{
File f = eFile_Open(fileName, FO_WRITE);
if(f)
int y;
bool done = false;
EditLine line = this.line;
- int c;
+ int c = 0;
for(y = this.y; y>= 0; y--)
{
c = (y == this.y) ? (Min(this.x-1, line.count-1)) : line.count-1;
if(key.ctrl)
{
int i;
- int length;
char * buffer = line1.buffer;
for(i = x1; i < line1.count; i++)
{
bool foundAlpha = false;
bool found = false;
int y = this.y;
- EditLine line, lastLine;
- int lastC, lastY;
+ EditLine line, lastLine = null;
+ int lastC = 0, lastY = 0;
for(line = this.line; (line && !found); line = line.prev, y--)
{
{
if(x <= line.count)
{
- byte * buffer = line.buffer;
+ byte * buffer = (byte *)line.buffer;
while(--x)
{
byte ch = buffer[x];
{
bool foundAlpha = false;
bool found = false;
- EditLine line, lastLine;
+ EditLine line = null, lastLine = null;
int y = this.y;
- int lastC, lastY, lastNumBytes;
+ int lastC = 0, lastY = 0, lastNumBytes = 0;
for(line = this.line; (line && !found); line = line.next, y++)
{
{
if(x < line.count)
{
- byte * buffer = line.buffer;
+ byte * buffer = (byte *)line.buffer;
while(++x)
{
byte ch = buffer[x];
{
if(style.stuckCaret) break;
{
+ /*
int th = space.h;
int textPos = 0;
int sx = 0, sy = this.y * this.space.h;
int maxW = clientSize.w - sx;
char * text = line.buffer;
+ */
if(!shift) SelDirty();
DirtyLine(this.y);
{
//Only indent back if you are exactly at one tab.
{
- bool whitespace = true;
+ //bool whitespace = true;
int i;
char * newline;
int putsize;
- int indentwidth;
+ int indentwidth = 0;
EditLine line = this.line;
//Only remove one tab if there is nothing else on the line.
bool _AddCh(unichar ch, int * addedSpacesPtr, int * addedTabsPtr)
{
EditLine line;
- int length, endX;
+ int length, endX = 0;
bool result;
ReplaceTextAction replaceAction = null;
AddCharAction addCharAction = null;
undoBuffer.Undo();
itemEditUndo.disabled = undoBuffer.curAction == 0;
itemEditRedo.disabled = undoBuffer.curAction == undoBuffer.count;
+
+ UpdateDirty();
+ SetSelectCursor();
+ SelectionEnables();
+
if(savedAction == undoBuffer.curAction)
{
modifiedDocument = false;
undoBuffer.Redo();
itemEditUndo.disabled = undoBuffer.curAction == 0;
itemEditRedo.disabled = undoBuffer.curAction == undoBuffer.count;
+
+ UpdateDirty();
+ SetSelectCursor();
+ SelectionEnables();
+
if(savedAction == undoBuffer.curAction)
{
modifiedDocument = false;
}
// BASIC OUTPUT
- bool AddS(char * string)
+ bool AddS(const char * string)
{
if(this)
{
bool ret = true;
- char * line;
+ const char * line;
int c, count;
int addedSpaces = 0, addedTabs = 0;
AddTextAction action = null;
{
if(string[c] == '\n' || string[c] == '\r')
{
- if(!AddToLine(line,count, true, addedSpaces ? null : &addedSpaces, addedTabs ? null : &addedTabs))
+ if(!AddToLine(line, count, true, addedSpaces ? null : &addedSpaces, addedTabs ? null : &addedTabs))
{
ret = false;
break;
}
}
- void PutS(char * string)
+ void PutS(const char * string)
{
if(this)
{
}
}
- void Printf(char * format, ...)
+ void Printf(const char * format, ...)
{
if(this)
{
}
}
- void SetContents(char * format, ...)
+ void SetContents(const char * format, ...)
{
if(this)
{
{
if(created)
{
- int w;
- int c, numLines;
+ int numLines;
EditLine line;
int x;
int checkX, checkY;
}
else
{
- EditLine oldLine = this.line;
+ //EditLine oldLine = this.line;
bool lastOne = false;
EditLine oldViewLine = this.viewLine;
bool figureSyntax = false;
}
else
{
- EditLine oldLine = this.line;
-
for(c=0, line = this.line.prev; line && c<numLines; line = line.prev, c++)
{
this.line = line;
itemEditRedo.disabled = undoBuffer.curAction == undoBuffer.count;
}
- EditBoxFindResult Find(char * text, bool matchWord, bool matchCase, bool isSearchDown)
+ EditBoxFindResult Find(const char * text, bool matchWord, bool matchCase, bool isSearchDown)
{
EditLine line;
int num;
return notFound;
}
- EditBoxFindResult FindInSelection(char * text, bool matchWord, bool matchCase, EditLine l2, int y2, int x2)
+ EditBoxFindResult FindInSelection(const char * text, bool matchWord, bool matchCase, EditLine l2, int y2, int x2)
{
EditLine line;
int y;
return result;
}
- bool Puts(char * string)
+ bool Puts(const char * string)
{
EditBox editBox = this.editBox;
BufferLocation start { editBox.line, editBox.y, editBox.x };
{
utf8Bytes[numBytes++] = ch;
utf8Bytes[numBytes] = 0;
- if(UTF8Validate(utf8Bytes))
+ if(UTF8Validate((char *)utf8Bytes))
{
editBox.AddCh(UTF8_GET_CHAR(utf8Bytes, numBytes));
numBytes = 0;