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 8854711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:56:48+00:00 2026-06-14T13:56:48+00:00

For AvalonEdit I have defined Comments in the xshd-File. Now, in my program, I

  • 0

For AvalonEdit I have defined “Comments” in the xshd-File. Now, in my program, I would like to determine whether a given offset lies inside or outside of a comment.

I did find some code on the net, namely:

http://community.sharpdevelop.net/forums/t/12793.aspx

However, I do not know how to receive the necessary objects (like CurrentContext) from my AvalonEdit-Object.

I’m hoping someone has created such a function before. Can you please post some code or point me in the right direction? (documentation, etc)

  • 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-14T13:56:50+00:00Added an answer on June 14, 2026 at 1:56 pm

    I’m not sure what the “current context” is in that example, but it’s only used to access the service container with the IHighlighter.
    You can get that directly from the TextEditor:

    bool IsInComment(int line, int column)
    {
        IHighlighter highlighter = textEditor.TextArea.GetService(typeof(IHighlighter)) as IHighlighter;
        if (highlighter == null)
            return false;
        int off = textEditor.Document.GetOffset(line, column);
        HighlightedLine result = highlighter.HighlightLine(document.GetLineByNumber(line));
        return result.Sections.Any(s => s.Offset <= off && s.Offset+s.Length >= off && s.Color.Name == "Comment");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone written an AvalonEdit XSHD file for Ruby syntax? I'm in need of
I want to cascade the SyntaxHighlighting Engine of AvalonEdit. I have 2 HighlightingDefinitions .
I have a WPF control (the ICSharpCode.AvalonEdit.TextEditor ) in a Winforms project inside an
I am writing a text editor using Avalon Edit. I would like to replace
I've got a custom composite WPF control (AvalonEdit) in my application that I'd like
I need to highlight all occurrences of selected word in AvalonEdit. I created an
Is it possible to use AvalonEdit control in a WPF application as an ironPython
I'm using AvalonEdit, and I want the user to always be able to see
I am trying to compile AvalonEdit for Silverlight, but I am not sure how
My windows forms application hosts AvalonEdit (the composite WPF control in question) in one

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.