<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ReleaseVersion>0.4</ReleaseVersion>
<Description>Crow project description</Description>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<EmbeddedResource Include="Styles\Spinner.style" />
<EmbeddedResource Include="Styles\MessageBox.style" />
<EmbeddedResource Include="Styles\Window.style" />
+ <EmbeddedResource Include="Styles\TextBox.style" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
--- /dev/null
+Fit = true
+Focusable = true
+Background = White
+Foreground = Black
+
using System.ComponentModel;
namespace Crow
-{
- [Serializable]
+{
[DefaultStyle("#Crow.Styles.Label.style")]
public class Label : GraphicObject
{
return;
if (value < 0)
_currentCol = 0;
- else if (value > lines [_currentLine].Count ())
- _currentCol = lines [_currentLine].Count ();
+ else if (value > lines [_currentLine].Length)
+ _currentCol = lines [_currentLine].Length;
else
_currentCol = value;
NotifyValueChanged ("CurrentColumn", _currentCol);
else if (value < 0)
_currentLine = 0;
else
- _currentLine = value;
+ _currentLine = value;
+ //force recheck of currentCol for bounding
+ int cc = _currentCol;
+ _currentCol = 0;
+ CurrentColumn = cc;
NotifyValueChanged ("CurrentLine", _currentLine);
}
}
}
}
+ [XmlIgnore]protected Char CurrentChar //ordered selection start and end positions
+ {
+ get {
+ return lines [CurrentLine] [CurrentColumn];
+ }
+ }
[XmlIgnore]protected Point selectionStart //ordered selection start and end positions
{
get {
}
}
+ public void GotoWordStart(){
+ CurrentColumn--;
+ //skip white spaces
+ while (char.IsWhiteSpace (this.CurrentChar) && CurrentColumn > 0)
+ CurrentColumn--;
+ while (!char.IsWhiteSpace (lines [CurrentLine] [CurrentColumn]) && CurrentColumn > 0)
+ CurrentColumn--;
+ if (char.IsWhiteSpace (this.CurrentChar))
+ CurrentColumn++;
+ }
+ public void GotoWordEnd(){
+ //skip white spaces
+ while (char.IsWhiteSpace (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
+ CurrentColumn++;
+ while (!char.IsWhiteSpace (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
+ CurrentColumn++;
+ if (!char.IsWhiteSpace (this.CurrentChar))
+ CurrentColumn++;
+ }
public void DeleteChar()
{
if (selectionIsEmpty) {
if (CurrentLine == 0)
return;
CurrentLine--;
- CurrentColumn = lines [CurrentLine].Count ();
+ CurrentColumn = lines [CurrentLine].Length;
lines [CurrentLine] += lines [CurrentLine + 1];
lines.RemoveAt (CurrentLine + 1);
NotifyValueChanged ("Text", Text);
}
CurrentColumn--;
lines [CurrentLine] = lines [CurrentLine].Remove (CurrentColumn, 1);
- } else {
- Debug.WriteLine (selectionEnd.ToString());
+ } else {
int linesToRemove = selectionEnd.Y - selectionStart.Y;
int l = selectionStart.Y;
namespace Crow
{
+ [DefaultStyle("#Crow.Styles.TextBox.style")]
public class TextBox : Label
{
#region CTOR
RegisterForGraphicUpdate();
}
}
- [XmlAttributeAttribute()][DefaultValue(true)]
- public override bool Focusable
- {
- get { return base.Focusable; }
- set { base.Focusable = value; }
- }
- [XmlAttributeAttribute()][DefaultValue("White")]
- public override Fill Background {
- get { return base.Background; }
- set { base.Background = value; }
- }
- [XmlAttributeAttribute()][DefaultValue("Black")]
- public override Fill Foreground {
- get { return base.Foreground; }
- set { base.Foreground = value; }
- }
protected override void onDraw (Context gr)
{
switch (key)
{
case Key.Back:
- if (!selectionIsEmpty)
- {
- // Text = Text.Remove(selectionStart, selectionEnd - selectionStart);
- // selReleasePos = -1;
- // currentCol = selBeginPos;
- }
- else
- this.DeleteChar();
+ this.DeleteChar();
break;
case Key.Clear:
break;
case Key.Delete:
if (selectionIsEmpty)
CurrentColumn++;
+ else if (e.Shift)
+ Interface.CurrentInterface.Clipboard = this.SelectedText;
this.DeleteChar ();
break;
case Key.Enter:
case Key.KeypadEnter:
+ if (!selectionIsEmpty)
+ this.DeleteChar ();
if (Multiline)
this.InsertLineBreak ();
else
SelRelease = -1;
break;
case Key.Home:
- //TODO
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point (CurrentColumn, CurrentLine);
+ if (e.Control)
+ CurrentLine = 0;
+ CurrentColumn = 0;
+ SelRelease = new Point (CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
if (e.Control)
CurrentLine = 0;
CurrentColumn = 0;
break;
case Key.End:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point (CurrentColumn, CurrentLine);
+ if (e.Control)
+ CurrentLine = int.MaxValue;
+ CurrentColumn = int.MaxValue;
+ SelRelease = new Point (CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
if (e.Control)
CurrentLine = int.MaxValue;
CurrentColumn = int.MaxValue;
break;
case Key.Insert:
- break;
- case Key.Left:
- CurrentColumn--;
- break;
- case Key.Right:
- CurrentColumn++;
+ if (e.Shift)
+ this.Insert (Interface.CurrentInterface.Clipboard);
+ break;
+ case Key.Left:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ if (e.Control)
+ GotoWordStart ();
+ else
+ CurrentColumn--;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
+ if (e.Control)
+ GotoWordStart ();
+ else
+ CurrentColumn--;
+ break;
+ case Key.Right:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ if (e.Control)
+ GotoWordEnd ();
+ else
+ CurrentColumn++;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
+ if (e.Control)
+ GotoWordEnd ();
+ else
+ CurrentColumn++;
break;
case Key.Up:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ CurrentLine--;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
CurrentLine--;
break;
case Key.Down:
- CurrentLine++;
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ CurrentLine++;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
+ CurrentLine++;
break;
case Key.Menu:
break;
case Key.NumLock:
break;
- case Key.PageDown:
+ case Key.PageDown:
break;
case Key.PageUp:
break;
public Queue<LayoutingQueueItem> LayoutingQueue;
public Queue<GraphicObject> GraphicUpdateQueue = new Queue<GraphicObject>();
-
+ public string Clipboard;
public static void RegisterForGraphicUpdate(GraphicObject g)
{
lock (CurrentInterface.GraphicUpdateQueue) {