/* $Id$ Part of XPCE Designed and implemented by Anjo Anjewierden and Jan Wielemaker E-mail: jan@swi.psy.uva.nl Copyright (C) 1998 University of Amsterdam. All rights reserved. */ :- module(pce_identifier_item, []). :- use_module(library(pce)). :- pce_begin_class(identifier_item, text_item, "Item for non-empty, canonised word"). variable(case, {sensitive,upper,lower} := sensitive, both, "Case mapping"). variable(blank, '{accept,stripped,canonise}|char' := canonise, both, "How to handle blank space"). selection(II, Selection:name) :<- "Get selection and canonise":: get(II, get_super, selection, Name0), get(II, case, CaseMap), canonise_case(CaseMap, Name0, Name1), get(II, blank, BlankMap), canonise_blanks(BlankMap, Name1, Selection), Selection \== ''. canonise_case(upper, Name, Upper) :- !, get(Name, upcase, Upper). canonise_case(lower, Name, Upper) :- !, get(Name, downcase, Upper). canonise_case(_, Name, Name). canonise_blanks(canonise, Name0, Name) :- !, get(Name0, strip, canonise, Name). canonise_blanks(stripped, Name0, Name) :- !, get(Name0, strip, both, Name). canonise_blanks(Mapped, Name0, Name) :- integer(Mapped), !, get(Name0, strip, canonise, Name1), new(S, string('%s', Name1)), send(S, translate, ' ', Mapped), get(S, value, Name), free(S). canonise_blanks(_, Name, Name). typed(II, Key:event_id) :-> "Properly handle completion":: ( Key == 32 % Space: completion -> true ; send(II, send_super, typed, Key) ). :- pce_end_class.