Giter Site home page Giter Site logo

frozenassassine / textcontrolbox-uwp Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 1.0 8.83 MB

A UWP based textbox with Syntaxhighlighting and support for very large amounts of text

License: MIT License

C# 100.00%
syntaxhighlighting textbox uwp linenumbers csharp textcontrolbox

textcontrolbox-uwp's Introduction

TextControlBox-UWP

๐Ÿค” What is TextControlBox?

A UWP based textbox with syntaxhighlighting and support for very large amount of text which is still in development.

Reason why I built it

UWP has a default Textbox and a RichTextBox. Both of them are very slow in rendering multiple thousand lines. The selection works also very slow. So I decided to create my own version of a Textbox.

๐Ÿ“ฅ Download

๐Ÿ” Features:

  • Viewing files with a million lines or more without performance issues
  • Syntaxhighlighting
  • Outstanding performance because it only renders the lines that are needed to display
  • Linenumbering
  • Linehighlighter
  • Json to create custom syntaxhighlighting
  • Highly customizable

โ— Problems:

  • Current text limit is 100 million characters
  • Currently there is no textwrapping
  • First version for WinUI with many problems and bugs, but working Github

๐Ÿšฉ Available languages:

  • Batch
  • Config file
  • C++
  • C#
  • CSV
  • CSS
  • GCode
  • Hex
  • Html
  • Java
  • Javascript
  • Json
  • Markdown
  • LaTex
  • PHP
  • Python
  • QSharp
  • Toml
  • Xml

๐Ÿš€ Usage:

Properties

- ScrollBarPosition (get/set)
- CharacterCount (get)
- NumberOfLines (get)
- CurrentLineIndex (get)
- SelectedText (get/set)
- SelectionStart (get/set)
- SelectionLength (get/set)
- ContextFlyoutDisabled (get/set)
- ContextFlyout (get/set)
- CursorSize (get/set)
- ShowLineNumbers (get/set)
- ShowLineHighlighter (get/set)
- ZoomFactor (get/set)
- IsReadonly (get/set)
- Text (get/set)
- RenderedFontSize (get)
- FontSize (get/set)
- FontFamily (get/set)
- Cursorposition (get/set)
- SpaceBetweenLineNumberAndText (get/set)
- LineEnding (get/set)
- SyntaxHighlighting (get/set)
- CodeLanguage (get/set)
- RequestedTheme (get/set)
- Design (get/set)
- static CodeLanguages (get/set) 
- VerticalScrollSensitivity (get/set)
- HorizontalScrollSensitivity (get/set)
- VerticalScroll (get/set)
- HorizontalScroll (get/set)
- CornerRadius (get/set)
- UseSpacesInsteadTabs (get/set)
- NumberOfSpacesForTab (get/set)

Functions

- SelectLine(index)
- GoToLine(index)
- SetText(text)
- LoadText(text)
- Paste()
- Copy()
- Cut()
- GetText()
- SetSelection(start, length)
- SelectAll()
- ClearSelection()
- Undo()
- Redo()
- ScrollLineToCenter(line)
- ScrollOneLineUp()
- ScrollOneLineDown()
- ScrollLineIntoView(line)
- ScrollTopIntoView()
- ScrollBottomIntoView()
- ScrollPageUp()
- ScrollPageDown()
- GetLineContent(line)
- GetLinesContent(startline, count)
- SetLineContent(line, text)
- DeleteLine(line)
- AddLine(position, text)
- FindInText(pattern)
- SurroundSelectionWith(value)
- SurroundSelectionWith(value1, value2)
- DuplicateLine(line)
- FindInText(word, up, matchCase, wholeWord)
- ReplaceInText(word, replaceword, up, matchCase, wholeword)
- ReplaceAll(word, replaceword, up, matchCase, wholeword)
- static GetCodeLanguageFromJson(jsondata)
- static SelectCodeLanguageById(identifier)
- Unload()
- ClearUndoRedoHistory()

Create custom syntaxhighlighting languages with json:

{
  "Highlights": [
    {
      "CodeStyle": { //optional delete when not used
        "Bold": true, 
        "Underlined": true, 
        "Italic": true
      },
      "Pattern": "REGEX PATTERN",
      "ColorDark": "#ffffff", //color in dark theme
      "ColorLight": "#000000" //color in light theme
    },
  ],
  "Name": "NAME",
  "Filter": "EXTENSION1|EXTENSION2", //.cpp|.c
  "Description": "DESCRIPTION",
  "Author": "AUTHOR"
}  

To bind it to the textbox you can use one of these ways:

TextControlBox textbox = new TextControlBox();

//Use a builtin language -> see list a bit higher
//Language identifiers are case intensitive
textbox.CodeLanguage = TextControlBox.GetCodeLanguageFromId("CSharp");

//Use a custom language:
var result = TextControlBox.GetCodeLanguageFromJson("JSON DATA");
if(result.Succeed)
     textbox.CodeLanguage = result.CodeLanguage; 

Create custom designs in C#:

textbox.Design = new TextControlBoxDesign(
    new SolidColorBrush(Color.FromArgb(255, 30, 30, 30)), //Background brush
    Color.FromArgb(255, 255, 255, 255), //Text color
    Color.FromArgb(100, 0, 100, 255), //Selection color
    Color.FromArgb(255, 255, 255, 255), //Cursor color
    Color.FromArgb(50, 100, 100, 100), //Linehighlighter color
    Color.FromArgb(255, 100, 100, 100), //Linenumber color
    Color.FromArgb(0, 0, 0, 0), //Linenumber background
    Color.FromArgb(100,255,150,0) //Search highlight color
    );

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributors:

If you want to contribute for this project, feel free to open an issue or a pull request.

๐Ÿ“ธ Images

textcontrolbox-uwp's People

Contributors

finn-freitag avatar frozenassassine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

finn-freitag

textcontrolbox-uwp's Issues

Enter not deleting selection

If enter gets pressed, the selection wont be deleted and instead a new line gets inserted and the selected content stays

Fix OutOfRange exceptions

Fix OutOfRange exceptions in TotalLines-list by using functions with OutOfRange-check, instead the direct index accessor

Add events

Add events

  • Textchanged
  • Selectionchanged
  • Zoomchanged

Implement tab-key functions

Implement functions for the tab-key:

  • Tab = insert tab
  • Tab on selected text = insert tab for every line in selection
  • Shift + Tab = remove tab
  • Shift + Tab on selected text = remove tab in every line in selection

Change the UndoStack to something better

Because the UndoStack can only store 1MB of data, the potential for large Undooperations is pretty weak.

A custom Stack using an Array or a List is a should be a way better alternative here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.