diff options
| -rw-r--r-- | LICENSE | 2 | ||||
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | README | 12 | ||||
| -rw-r--r-- | dlu.1 | 15 | ||||
| -rwxr-xr-x | dlu.py | 5 |
5 files changed, 28 insertions, 7 deletions
@@ -1,6 +1,6 @@ ISC License -© 2016 Mattias Andrée <m@maandree.se> +© 2016, 2026 Mattias Andrée <m@maandree.se> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -11,6 +11,7 @@ COMMAND = dlu PKGNAME = dlu all: + @: install: install-base install-doc install-base: install-cmd install-copyright @@ -30,10 +30,18 @@ DESCRIPTION Modifies and returns a word so that it can be used to compare against known words in the dictionary. - The default implementation of this function converts the - word to lower case using Python's string class's + The default implementation of this function converts + the word to lower case using Python's string class's lower() function. + before(word1 : str, word2 : str) -> bool + Collation function that checks that word1 comes before + word2 in the dictionary (if so, it returns True, + otherwise it returns False). + + The default implementation of this function compares + in C locale. + get() -> tuple Returns a 3-tuple containing, in order: the filename of the scanned dictionary, a list of the last word on @@ -61,6 +61,19 @@ to lower case using Python's string class's .BR lower () function. .TP +.BR before "(\fIword1\fP : str, \fIword2\fP : str) -> bool" +Collation function that checks that +.I word1 +comes before +.I word2 +in the dictionary (if so, it returns +.BR True , +otherwise it returns +.BR False ). + +The default implementation of this function compares +in C locale. +.TP .BR get "() -> tuple" Returns a 3-tuple containing, in order: the filename of the scanned dictionary, a list of the last word on @@ -75,5 +88,3 @@ Print a list of all dictionaries. .TP .B ~/.config/dlu/dlurc The configuration file. -.SH BUGS -Please report bugs to m@maandree.se @@ -2,7 +2,7 @@ import sys, os -global dictionary_name, sought_word, display_envs, x_reads, reads, wordmod, standard_page_remap, load_dictionary, open_dictionary +global dictionary_name, sought_word, display_envs, x_reads, reads, wordmod, standard_page_remap, load_dictionary, open_dictionary, before ## Parse command line. def usage(): @@ -43,6 +43,7 @@ if not f_list: reads = dict((disp, list(x_reads)) for disp in display_envs) reads[None] = [lambda f, p : ['jfbview', '-p', p, '--', f]] wordmod = lambda x : x.lower() + before = lambda a, b: a < b def standard_page_remap(offset, multiple = 1, multiple_offset = 0): return lambda p : (0 if p < multiple_offset else p - multiple_offset) // multiple + offset def open_dictionary(filename, page): @@ -132,7 +133,7 @@ lasts = [(i, word) for i, word in enumerate(lasts)] for i, word in lasts: word = wordmod(word) - if sought_word <= word: + if not before(word, sought_word): page = i break else: |
