HTMLManager.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Collections.Generic;
  2. using NTERA.EmuEra.Game.EraEmu.Sub;
  3. namespace NTERA.EmuEra.Game.EraEmu.Display
  4. {
  5. //TODO:1810~
  6. /* Emuera用Htmlもどきが実装すべき要素
  7. * (できるだけhtmlとConsoleDisplayLineとの1:1対応を目指す。<b>と<strong>とか同じ結果になるタグを重複して実装しない)
  8. * <p align=""></p> ALIGNMENT命令相当・行頭から行末のみ・行末省略可
  9. * <nobr></nobr> PRINTSINGLE相当・行頭から行末のみ・行末省略可
  10. * <b><i><u><s> フォント各種・オーバーラップ問題は保留
  11. * <button value=""></button> ボタン化・htmlでは明示しない限りボタン化しない
  12. * <font face="" color="" bcolor=""></font> フォント指定 色指定 ボタン選択中色指定
  13. * 追加<!-- --> コメント
  14. * <nonbutton title='~~'>
  15. * <img src='~~' srcb='~~'>
  16. * <shape type='rect' param='0,0,0,0'>
  17. * エスケープ
  18. * &amp; &gt; &lt; &quot; &apos; &<>"' ERBにおける利便性を考えると属性値の指定には"よりも'を使いたい。HTML4.1にはないがaposを入れておく
  19. * &#nn; &#xnn; Unicode参照 #xFFFF以上は却下
  20. */
  21. /* このクラスがサポートすべきもの
  22. * html から ConsoleDisplayLine[] //主に表示用
  23. * ConsoleDisplayLine[] から html //現在の表示をstr化して保存?
  24. * html から ConsoleDisplayLine[] を経て html //表示を行わずに改行が入る位置のチェックができるかも
  25. * html から PlainText(非エスケープ)//
  26. * Text から エスケープ済Text
  27. */
  28. /// <summary>
  29. /// EmueraConsoleのなんちゃってHtml解決用クラス
  30. /// </summary>
  31. public static class HtmlManager
  32. {
  33. public static string[] HtmlTagSplit(string str)
  34. {
  35. List<string> strList = new List<string>();
  36. StringStream st = new StringStream(str);
  37. int found = -1;
  38. while (!st.EOS)
  39. {
  40. found = st.Find('<');
  41. if (found < 0)
  42. {
  43. strList.Add(st.Substring());
  44. break;
  45. }
  46. if (found > 0)
  47. {
  48. strList.Add(st.Substring(st.CurrentPosition, found));
  49. st.CurrentPosition += found;
  50. }
  51. found = st.Find('>');
  52. if(found < 0)
  53. return null;
  54. found++;
  55. strList.Add(st.Substring(st.CurrentPosition, found));
  56. st.CurrentPosition += found;
  57. }
  58. string[] ret = new string[strList.Count];
  59. strList.CopyTo(ret);
  60. return ret;
  61. }
  62. }
  63. }