Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A text editor specialized for displaying and editing code documents. Written in pure Swift.

License

NotificationsYou must be signed in to change notification settings

CodeEditApp/CodeEditTextView

Repository files navigation

CodeEditTextView

A text editor specialized for displaying and editing code documents. Features include basic text editing, extremely fast initial layout, support for handling large documents, customization options for code documents.

GitHub releaseGithub TestsGitHub Repo starsGitHub forksDiscord Badge

Important

This package contains a text view suitable for replacingNSTextView in some,specific cases. If you want a text view that can handle things like: right-to-left text, custom layout elements, or feature parity with the system text view, consider usingSTTextView orNSTextView. TheTextView exported by this library is designed to lay out documents made up of lines of text. It also does not attempt to reason about the contents of the document. If you're looking to editsource code (indentation, syntax highlighting) consider using the parent libraryCodeEditSourceEditor.

Documentation

This package is fully documentedhere.

Usage

This package exports a primaryTextView class. TheTextView class is anNSView subclass that can be embedded in a scroll view or used standalone. It parses and renders lines of a document and handles mouse and keyboard events for text editing. It also renders styled strings for use cases like syntax highlighting.

import CodeEditTextViewimport AppKit/// # ViewController/// /// An example view controller for displaying a text view embedded in a scroll view.classViewController:NSViewController,TextViewDelegate{privatevarscrollView:NSScrollView!privatevartextView:TextView!vartext:String="func helloWorld() {\n\tprint(\"hello world\")\n}"varfont:NSFont!vartextColor:NSColor!overridefunc loadView(){textView=TextView(            string: text,            font: font,            textColor: textColor,            lineHeightMultiplier:1.0,            wrapLines:true,            isEditable:true,            isSelectable:true,            letterSpacing:1.0,            delegate:self)        textView.translatesAutoresizingMaskIntoConstraints=false        scrollView=NSScrollView()        scrollView.translatesAutoresizingMaskIntoConstraints=false        scrollView.hasVerticalScroller=true        scrollView.hasHorizontalScroller=true        scrollView.documentView= textViewself.view= scrollViewNSLayoutConstraint.activate([            scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),            scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),            scrollView.topAnchor.constraint(equalTo: view.topAnchor),            scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor)])        textView.updateFrameIfNeeded()}}

License

Licensed under theMIT license.

Dependencies

Special thanks toMatt Massicotte for the great work he's done!

PackageSourceAuthor
TextStoryGitHubMatt Massicotte
swift-collectionsGitHubApple

Related Repositories

        CodeEdit        

CodeEditSourceEditor

     CodeEditKit     

CodeEditLanguages

    CodeEdit CLI    

About

A text editor specialized for displaying and editing code documents. Written in pure Swift.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp