Beispiel #1
0
 public void click(double x, double y)
 {
     Line now = text.start.line;
     for (; ; ) {
         y -= now.start.next.format.Height;
         if (y < 0) break;
         now = now.next;
         if (now.start.kind == Kind_word.Start) {
             now = now.before;
             break;
         }
     }
     for (word = now.start.next; ; word = word.next) {
         if (word.kind == Kind_word.Break || word.kind == Kind_word.End) {
             pos = 0;
             break;
         }
         if (x < word.format.WidthIncludingTrailingWhitespace) {
             pos = word.get_pos(x);
             break;
         }
         x -= word.format.WidthIncludingTrailingWhitespace;
     }
 }
Beispiel #2
0
 public void del()
 {
     if (pos == 0 && word.length == 1) {
         Word removed_word = word;
         word = word.before;
         pos = word.length;
         removed_word.remove();
         if ((word.kind == Kind_word.Letter || word.kind == Kind_word.Space || word.kind == Kind_word.MultiByte) && word.next.kind == word.kind) {
             word.Str += word.next.str;
             word.next.remove();
         }
     }
     else {
         word.Str = word.Str.Remove(pos, 1);
     }
 }
Beispiel #3
0
 //スペース飛ばし
 void neo()
 {
     now = now.next_over_space;
     if (now.kind == Kind_word.End) throw new Exception_end();
 }
Beispiel #4
0
 public void backspace()
 {
     if (pos == 0) {
         word = word.before;
         pos = word.length;
     }
     if (word.kind == Kind_word.Start) return;
     pos--;
     del();
 }
Beispiel #5
0
 public void move_back()
 {
     if (word.kind == Kind_word.Start) {
         pos = 1; return;
     }
     loop:
     if (pos < 0) {
         word = word.before;
         pos += word.length;
         goto loop;
     }
 }
Beispiel #6
0
 public void move_vertical(int count)
 {
     Line line = word.line;
     for (Word now = line.start; now != word; now = now.next) {
         pos += now.length;
     }
     if (count > 0) {
         for (int i = 0; i < count; i++) {
             line = line.next;
             if (line.start.kind == Kind_word.Start) {
                 word = line.start.before; pos = 0;
                 line = line.before;
                 return;
             }
         }
     }
     else if (count < 0) {
         for (int i = 0; i < -count; i++) {
             if (line.start.kind == Kind_word.Start) {
                 word = line.start; pos = 1;
                 return;
             }
             line = line.before;
         }
     }
     word = line.start;
     move(false);
 }
Beispiel #7
0
 public Word(String str, Kind_word kind)
 {
     this.str = str;
     this.kind = kind;
     this.format = new FormattedText(str, new System.Globalization.CultureInfo("ja"), FlowDirection.LeftToRight, FONT_FAMILY, 15.0, Brushes.Black);
     next = before = this;
 }
Beispiel #8
0
 public Point get_position()
 {
     Point ret = new Point(0, 0);
     if (word.kind == Kind_word.Break) {
         if (pos == 0) {
             word = word.before;
             pos = word.length;
         }
     }
     for (Line now = text.start.line; ; now = now.next) {
         ret.Y += now.start.next.format.Height;
         if (now == word.line) {
             if (word.kind == Kind_word.Break || word.kind == Kind_word.Start) return ret;
             for (Word w = now.start.next; w != word; w = w.next) {
                 ret.X += w.format.WidthIncludingTrailingWhitespace;
             }
             return ret;
         }
     }
 }
Beispiel #9
0
 public Line(Word start)
 {
     next = before = this;
     this.start = start;
 }
Beispiel #10
0
 public Word(Text text)
 {
     this.text = text;
     next = before = this;
     line = new Line(this);
     this.str = "\0";
     this.order = 0;
     this.kind = Kind_word.Start;
     text.word_count++;
     this.connect(new Word("\0", Kind_word.End));
 }
Beispiel #11
0
 public Compiler(Word now)
 {
     this.now = now;
 }
Beispiel #12
0
 void nex()
 {
     now = now.next;
     if (now.kind == Kind_word.End) throw new Exception_end();
 }
Beispiel #13
0
 //改行とスペース飛ばし
 void neox()
 {
     head:
     now = now.next_over_space;
     if (now.kind == Kind_word.Break) goto head;
     if (now.kind == Kind_word.End) throw new Exception_end();
 }
Beispiel #14
0
 public void delete()
 {
     if (pos == word.length) {
         word = word.next;
         pos = 0;
     }
     if (word.kind == Kind_word.End) return;
     del();
 }
Beispiel #15
0
 public static bool In_call(Word now)
 {
     if (Type_value.Call_start <= now.type && now.type <= Type_value.Call_end) return true;
     else return false;
 }
Beispiel #16
0
 public String delete(Target to)
 {
     String ret = "";
     Target start, end;
     if (word == to.word) {
         if (pos == to.pos) return "";
         else if (pos < to.pos) {
             ret += word.Str.Substring(pos, to.pos - pos);
             word.Str = word.Str.Remove(pos, to.pos - pos);
         }
         else {
             ret += word.Str.Substring(to.pos, pos - to.pos);
             word.Str = word.Str.Remove(to.pos, pos - to.pos);
             pos = to.pos;
         }
         if (word.Str.Length == 0) {
             word.remove();
             word = word.before;
             pos = word.length;
         }
         goto finish;
     }
     else if (word.order < to.word.order) {
         start = this; end = to;
     }
     else {
         start = to; end = this;
     }
     ret += start.word.Str.Substring(start.pos);
     start.word.Str = start.word.Str.Substring(0, start.pos);
     if (start.word.Str.Length == 0) {
         start.word.remove();
         if (start == this) {
             word = word.before;
             pos = word.length;
         }
     }
     for (Word now = start.word.next; ; ) {
         if (now == end.word) {
             ret += now.Str.Substring(0, end.pos);
             end.word.Str = now.Str.Substring(end.pos, now.length - end.pos);
             if (now.Str.Length == 0) {
                 if (end == this) {
                     word = now.next;
                     pos = 0;
                 }
                 now.remove();
             }
             else if (end == this) pos = 0;
             break;
         }
         ret += now.Str;
         now.remove();
         now = now.next;
     }
     finish:
     if (word.kind == Kind_word.Letter || word.kind == Kind_word.Space || word.kind == Kind_word.MultiByte) {
         if (pos == 0 && word.kind == word.before.kind) {
             word = word.before;
             pos = word.length;
             word.Str += word.next.Str;
             word.next.remove();
         }
         else if (pos == word.length && word.kind == word.next.kind) {
             word.Str += word.next.Str;
             word.next.remove();
         }
     }
     return ret;
 }
Beispiel #17
0
 public void connect(Word item)
 {
     item.before = this;
     item.next = next;
     next.before = item;
     this.next = item;
     //
     item.text = this.text;
     item.line = this.line;
     text.word_count++;
     if (item.next.order - this.order <= 1) {
         Word now = text.start;
         if (now == null) now = this;
         int n = Int32.MaxValue / text.word_count;
         for (int i = 0; i < text.word_count; i++) {
             now.order = n * i;
             now = now.next;
         }
     }
     else item.order = (this.order + item.next.order) / 2;
     if (item.kind == Kind_word.Break) {
         Line new_line = new Line(item);
         line.connect(new_line);
         for(Word now = item; ; ) {
             now.line = new_line;
             now = now.next;
             if (now.kind == Kind_word.Break || now.kind == Kind_word.End) break;
         }
     }
 }
Beispiel #18
0
 public void input(String text, bool call_select)
 {
     if (pos == 0) word = word.before;
     else if (pos < word.length) {
         word.split(pos);
     }
     List<Word> new_words = split(text);
     int i = 0;
     if ((word.kind == Kind_word.Letter || word.kind == Kind_word.Number || word.kind == Kind_word.Space || word.kind == Kind_word.MultiByte) && word.kind == new_words[0].kind) {
         word.Str += new_words[0].str;
         i = 1;
     }
     for ( ; i < new_words.Count; i++) {
         word.connect(new_words[i]);
         word = new_words[i];
     }
     pos = word.length;
     if ((word.kind == Kind_word.Letter || word.kind == Kind_word.Number || word.kind == Kind_word.Space || word.kind == Kind_word.MultiByte) && word.kind == word.next.kind)
     {
         word.Str += word.next.str;
         word.next.remove();
     }
     else
     {
       //now programing
     }
     if (call_select)select();
     count += text.Length;
 }
Beispiel #19
0
 public Target(int count, Text text)
 {
     this.text = text;
     word = text.start;
     pos = count + 1;
     this.count = count;
     move(true);
     compile = html_compile;
 }
Beispiel #20
0
 public void move_next(bool can_over)
 {
     if (word.kind == Kind_word.End) {
         pos = 0;
         return;
     }
     loop:
     if (pos > word.length) {
         pos -= word.length;
         word = word.next;
         if (word.kind == Kind_word.Break) {
             if (can_over == false) {
                 pos = 0;
                 return;
             }
         }
         else if (word.kind == Kind_word.End) {
             pos = 0;
             return;
         }
         goto loop;
     }
 }
Beispiel #21
0
 public Target(Target origin)
 {
     word = origin.word;
     pos = origin.pos;
     text = origin.text;
     compile = origin.compile;
 }
Beispiel #22
0
 public Text(Text_page canvas)
 {
     this.canvas = canvas;
     start = new Word(this);
     from = new Target(0, this); to = null;
 }
Beispiel #23
0
 public void tag_compile()
 {
     Tag_element here = null;
     Tag_attribute tag_attribute = null;
     Type_value check_type = Type_value.Tag_name;
     String letter = null;
     for (; ; )
     {
         if ((letter = html_name_compile(check_type, tags.Last(), Brushes.Aqua)) != null)
         {
             if (here == null)
             {
                 here = new Tag_element() { name = letter };
                 check_type = Type_value.Tag_attribute;
             }
             else
             {
                 switch(letter) {
                     case "id":
                         here.id = now.str;
                         if (ids.ContainsKey(now.str) == false) ids.Add(letter, here);
                         else throw new Exception_error();
                         break;
                     case "name":
                         here.nm = now.str;
                         if (names.ContainsKey(now.str) == false) names.Add(letter, here);
                         break;
                     case "class":
                         here.cls = now.str;
                         if (classes.ContainsKey(now.str) == false) classes.Add(letter, here);
                         break;
                     default:
                         tag_attribute = new Tag_attribute() { name = now.str };
                         here.attributes.Add(tag_attribute);
                         break;
                 }
                 now.item = here;
             }
             neox();
             if (now.kind == Kind_word.Equal)
             {
                 neox();
                 if (now.kind == Kind_word.Double_quote || now.kind == Kind_word.Single_quote)
                 {
                     string_compile(now.kind, Type_value.Tag_attribute_value, tag_attribute);
                     neox();
                 }
             }
         }
         else if (now.kind == Kind_word.Slash)
         {
             now.color = Brushes.Blue;
             nex();
             if (now.kind == Kind_word.Compare_Right)
             {
                 now.color = Brushes.Blue;
                 //now programing
                 return;
             }
             else throw new Exception_error();
         }
         else if (now.kind == Kind_word.Compare_Right)
         {
             now.color = Brushes.Blue;
             tags.Add(here);
             if (here.name == "style")
             {
                 css_comile(Kind_word.Compare_Left);
                 now = now.before;
             }
             else if (here.name == "script")
             {
                 //++js_compile();
             }
             return;
         }
         else throw new Exception_error();
     }
 }