Profile Picture

How the text can be replaced by tab whih NSelection?

Posted By Junghyron Ryu 9 Months Ago
Author
Message
Junghyron Ryu
Question Posted 9 Months Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 3 days ago @ 9:07 AM
Posts: 6, Visits: 82
I'm trying to replace the specific text (space or special text) to tab.
First, the text is selected by NSelection. 
But it does not have method for InsertTab.
How can I do this?

Nevron Support
Posted 9 Months Ago
View Quick Profile
Supreme Being

Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,034, Visits: 3,710
Hi Junghyron,

You can use the following code insert a tab at the currently selected text selection:

richTextView.View.Selection.InsertText("\t");

If the selection object currently selects a range then the text will be replaced by a tab character. 

We hope this helps - let us know if you meet any problems.




Best Regards,
Nevron Support Team



Junghyron Ryu
Posted 9 Months Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 3 days ago @ 9:07 AM
Posts: 6, Visits: 82
For more information, I used NTextAtom as follows:
Where '\tab' means the tab in the text and it will be replaced to tab with width of 50.

// init find settings
NFindSettings settings = new NFindSettings();
settings.FindWhat = @"\tab";
settings.SearchDirection = ENSearchDirection.Forward;

// find all occurances
NRangeI textRange = NRangeI.Zero;
NSelection selection = view.EditingRoot.Selection;

while (view.EditingRoot.FindNext(settings, ref textRange))
{
  selection.SelectRange(textRange);
  NTabInline line = new NTabInline();
  line.TabWidth = 50;
  NTextAtom textAtom = new NInlineAtom(line);
  selection.InsertAtom(textAtom);
 }

 // move caret to beginning of document
 selection.MoveCaret(ENCaretMoveDirection.DocumentBegin, false);

Nevron Support
Posted 9 Months Ago
View Quick Profile
Supreme Being

Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)Supreme Being (4,298 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,034, Visits: 3,710
Hi Junghyron,

Yes, that is also an alternative way to insert it (especially if you want to specify the tab width). Do you meet any problems with this approach?

Best Regards,
Nevron Support Team



Junghyron Ryu
Posted 9 Months Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 3 days ago @ 9:07 AM
Posts: 6, Visits: 82
I just leave a comment to the other users how NTextAtom can be used.
This issue was solved.

Thank you Nevron Support Team





Similar Topics


Reading This Topic