Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>print("using System; </code></pre> <p>using System.Collections; using System.Collections.Generic; using System.Text;</p> <p>namespace NotepadOne {</p> <p>public class TextModel {</p> <pre><code>private String[] lines; private int selectionStart; private int cursorPosition; public TextModel() { } public String[] Lines { get { return lines; } set { lines = value; } } public int SelectionStart { get { return selectionStart; } set { selectionStart = value; } } public int CursorPosition { get { return cursorPosition; } set { cursorPosition = value; } } public void InsertControlPText() { lines[lines.Length - 1] += "ControlP"; } public void InsertParagraphTags() { int cursorLine = CursorLine(); String[] newlines = new String[lines.Length + 2]; for (int i = 0; i &lt;= cursorLine; i++) { newlines[i] = lines[i]; } newlines[cursorLine + 1] = ""; newlines[cursorLine + 2] = "&lt;P&gt;&lt;/P&gt;"; for (int i = cursorLine + 1; i &lt; lines.Length; i++) { newlines[i + 2] = lines[i]; } lines = newlines; selectionStart = NewSelectionStart(cursorLine + 2); } private int CursorLine() { int length = 0; int lineNr = 0; foreach (String s in lines) { if (length &lt;= SelectionStart &amp;&amp; SelectionStart &lt;= length + s.Length + 2) { break; length += s.Length + Environment.NewLine.Length; lineNr++; } lineNr++; } return lineNr; } private int NewSelectionStart(int cursorLine) { int length = 0; for (int i = 0; i &lt; cursorLine; i++) { length += lines[i].Length + Environment.NewLine.Length; } return length + 3; } </code></pre> <p>} } ");</p> <p>The InsertParagraphTags method is called by pressing the enter key in the textbox.</p> <p>BTW, the break here is that there is a subscript out of range error if you try to hit enter at the end of the text. I'm sure I could figure out how to get around this but then my code won't look like his code; which is what I'm trying to learn. </p> <p>Randy</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload