2626import GObject from "gi://GObject" ;
2727import Gtk from "gi://Gtk?version=4.0" ;
2828import Pango from "gi://Pango" ;
29+ import Adw from "gi://Adw?version=1" ;
2930
3031import { find } from "linkifyjs" ;
3132
3233import { ITag , Note } from "./util.js" ;
33- import { style_manager } from "./themeselector.js" ;
3434import { Style } from "./util.js" ;
3535
3636class AbstractStickyNote extends Gtk . TextView {
@@ -97,11 +97,15 @@ class AbstractStickyNote extends Gtk.TextView {
9797
9898 remove_listeners ( ) { }
9999
100+ style_manager ! : Adw . StyleManager ;
101+
100102 constructor (
101103 note ?: Note ,
102104 ) {
103105 super ( ) ;
104106
107+ this . style_manager = Adw . StyleManager . get_default ( ) ;
108+
105109 this . register_tags ( ) ;
106110 if ( note ) this . note = note ;
107111
@@ -159,7 +163,7 @@ class AbstractStickyNote extends Gtk.TextView {
159163 if ( ! this . note ) return ;
160164 let color ;
161165
162- if ( style_manager . dark ) {
166+ if ( this . style_manager . dark ) {
163167 const accent_color = this . get_style_context ( ) . lookup_color (
164168 "accent_fg_color" ,
165169 ) ;
@@ -190,8 +194,8 @@ class AbstractStickyNote extends Gtk.TextView {
190194
191195 this . link_tag . underline = Pango . Underline . SINGLE ;
192196
193- if ( style_manager . system_supports_color_schemes ) {
194- style_manager . connect (
197+ if ( this . style_manager . system_supports_color_schemes ) {
198+ this . style_manager . connect (
195199 "notify::dark" ,
196200 this . update_link_tag_color . bind ( this ) ,
197201 ) ;
@@ -415,7 +419,7 @@ export class WriteableStickyNote extends AbstractStickyNote {
415419 constructor ( note ?: Note ) {
416420 super ( note ) ;
417421
418- this . buffer . connect_after ( ' insert-text' , ( buffer , loc , text , length ) => {
422+ this . buffer . connect_after ( " insert-text" , ( buffer , loc , text , length ) => {
419423 this . on_text_inserted ( buffer , loc , text , length ) ;
420424 } ) ;
421425
@@ -475,8 +479,13 @@ export class WriteableStickyNote extends AbstractStickyNote {
475479 this . change ( "tags" , tags ) ;
476480 }
477481
478- on_text_inserted ( buffer : Gtk . TextBuffer , loc : Gtk . TextIter , text : string , length : number ) {
479- if ( text === '\n' ) {
482+ on_text_inserted (
483+ buffer : Gtk . TextBuffer ,
484+ loc : Gtk . TextIter ,
485+ text : string ,
486+ length : number ,
487+ ) {
488+ if ( text === "\n" ) {
480489 const start_iter = loc . copy ( ) ;
481490 start_iter . backward_char ( ) ;
482491 start_iter . set_line_offset ( 0 ) ;
@@ -494,15 +503,17 @@ export class WriteableStickyNote extends AbstractStickyNote {
494503 start_iter . set_line_offset ( 0 ) ;
495504 buffer . delete ( start_iter , loc ) ;
496505 } else {
497- buffer . insert ( loc , bullet + ' ' , - 1 ) ;
506+ buffer . insert ( loc , bullet + " " , - 1 ) ;
498507 }
499- } else {
508+ } else {
500509 const search_limit = start_iter . copy ( ) ;
501510 const search_end = start_iter . copy ( ) ;
502511 search_limit . forward_chars ( 10 ) ;
503512
504- search_end . forward_find_char ( ( ch ) => { return ch === ' ' } , search_limit ) ;
505- search_end . forward_char ( )
513+ search_end . forward_find_char ( ( ch ) => {
514+ return ch === " " ;
515+ } , search_limit ) ;
516+ search_end . forward_char ( ) ;
506517 const chars = buffer . get_text ( start_iter , search_end , false ) ;
507518
508519 const ordered_regex_pattern = / ^ \d + \. $ / ;
@@ -513,7 +524,9 @@ export class WriteableStickyNote extends AbstractStickyNote {
513524 const line_end = loc . copy ( ) ;
514525 line_end . backward_char ( ) ;
515526
516- if ( line_end . get_line_offset ( ) === current_order . toString ( ) . length + 2 ) {
527+ if (
528+ line_end . get_line_offset ( ) === current_order . toString ( ) . length + 2
529+ ) {
517530 start_iter . set_line_offset ( 0 ) ;
518531 buffer . delete ( start_iter , loc ) ;
519532 } else {
0 commit comments