Skip to content

A port of npm write-good to vala for Gtk.TextView and Gtk.SourceView

License

Notifications You must be signed in to change notification settings

ThiefMD/libwritegood-vala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libwritegood

A port of write good, 3 shell scripts to improve your writing, or "My Ph.D. advisor rewrote himself in bash.", and How I reverse-engineered the Hemingway Editor - a popular writing app - and built my own from a beach in Thailand for Gtk TextView.

Languages

Currently, we have:

en_US

Requirements

Ubuntu

meson
ninja-build
valac
cmake
libgtk-3-dev

Fedora

vala
meson
ninja-build
cmake
gtk3-devel

Usage

If your build system is meson, we recommend using the wrap depenency system

libwritegood.wrap

[wrap-git]
directory=libwritegood
url=https://github.com/ThiefMD/libwritegood-vala.git
revision=master

Place the libwritegood.wrap in subprojects directory in your project.

In your meson.build, add:

writegood_dep = dependency('writegood-0.1', fallback : [ 'writegood', 'libwritegood_dep' ])

Then add writegood_dep to your dependencies.

Attaching to your TextView

This example is with Gtk.SourceView, but a Gtk.TextView will also work.

var manager = Gtk.SourceLanguageManager.get_default ();
var language = manager.guess_language (null, "text/markdown");
var view = new Gtk.SourceView ();
buffer = new Gtk.SourceBuffer.with_language (language);
buffer.highlight_syntax = true;
view.set_buffer (buffer);
view.set_wrap_mode (Gtk.WrapMode.WORD);

//
// Enable write-good
//

checker = new WriteGood.Checker ();
checker.set_language ("en_US");
checker.attach (view);

//
// Quick check only scans around the last check cursor position, and
// and the current cursor position
//
buffer.changed.connect (() => {
    checker.quick_check ();
});

//
// Recheck all will scan the entire document
//
buffer.paste_done.connect ((clipboard) => {
    checker.recheck_all ();
});

Building Examples

After running meson build inside of the build directory run meson configure -Denable_examples=true. This will build the hello-writegood app that can be used for testing.

About

A port of npm write-good to vala for Gtk.TextView and Gtk.SourceView

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published