Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:24:13+00:00 2026-06-08T03:24:13+00:00

I am currently using AvalonEdit to develop a Movie Script editor in .NET 4.

  • 0

I am currently using AvalonEdit to develop a Movie Script editor in .NET 4.

Each element type in a script (i.e.: Character, dialog line, etc.) should have a right margin. In other words, after a certain number of characters per line, the following ones should go on another line.

Is it possible to assign a right margin per DocumentLine, or are we forced to handle each input individually, and determine when we have to skip to the next line ?

I tried using this approach, but having to calculate when to move, replace text and reposition the caret is not trivial and would require quite a bit of work. Unless I absolutely need to, I’d like to avoid this approach.

What alternatives are there to having right margins per DocumentLine ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:24:15+00:00Added an answer on June 8, 2026 at 3:24 am

    This element generator will introduce a line break after every 20 columns:

    public class WrapAtCol20 : VisualLineElementGenerator
    {
        public override int GetFirstInterestedOffset(int startOffset)
        {
            DocumentLine line = CurrentContext.Document.GetLineByOffset(startOffset);
            int col = startOffset - line.Offset;
            int wrapCol = ((col / 20) + 1) * 20;
            if (wrapCol < line.Length) {
                return line.Offset + wrapCol;
            }
            return -1;
        }
    
        public override VisualLineElement ConstructElement(int offset)
        {
            return new WrapElement();
        }
    
        class WrapElement : VisualLineElement
        {
            public WrapElement() :  base(visualLength: 1, documentLength: 0)
            {
            }
    
            public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
            {
                return new TextEndOfLine(1);
            }
        }
    }
    

    Note that this may interact poorly with the upper-casing generator – that one generates a single element for the whole text that will be upper-cased, which prevents other generators from inserting an element in between. The solution for that would be to change AvalonEdit so that the upper-casing can be handled by a colorizer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently using Telerik ASP .NET MVC Controls version 2011.2.712 Hello all, I am trying
Im currently using vs2008 with asp.net mvc framework for web development. Im missing a
Im currently using a method that looks like the following code to add script
I'm currently using VS2005 Profesional and .NET 2.0, and since our project is rather
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
Currently using Google Analytics as a supplement to our paid tracking software, but neither
Currently using MySQL version 5.1.6 This is my first real world build and so
Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
I currently using android NDK to write some native code in C. I have
I'm currently using the NEST ElasticSearch C# Library for interacting with ElasticSearch. My project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.