[prev in list] [next in list] [prev in thread] [next in thread]
List: squeak-dev
Subject: [squeak-dev] The Trunk: Collections-mt.1031.mcz
From: commits () source ! squeak ! org
Date: 2023-03-29 9:43:21
Message-ID: 20230329094326.2EE2714D63A () mail ! squeak ! org
[Download RAW message or body]
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.1031.mcz
==================== Summary ====================
Name: Collections-mt.1031
Author: mt
Time: 29 March 2023, 11:43:16.766107 am
UUID: 90b7b1a5-0369-5542-9507-80d32a98cc4a
Ancestors: Collections-mt.1030
Document and expand on the notion of "plain text" as a property that can be checked \
on any String or Text.
See commentary in #isPlainText for more inforamtion. Add #hasAnyAttribute to be used \
if a more strict check is necessary.
=============== Diff against Collections-mt.1030 ===============
Item was added:
+ ----- Method: String>>asPlainText (in category 'converting') -----
+ asPlainText
+ "For compatibility with Text"
+ ^self!
Item was added:
+ ----- Method: String>>isPlainText (in category 'testing') -----
+ isPlainText
+ "For compatibility with Text"
+ ^true!
Item was added:
+ ----- Method: Text>>asPlainText (in category 'converting') -----
+ asPlainText
+ "Answer a copy of the receiver that represents text that has no attributes \
substantially related to the visual representation of glyphs. If the receiver \
represents already plain text, just return it. Thus, do not rely on this method to \
always answer a copy." +
+ self isPlainText ifTrue: [^ self].
+ ^ self copy removeAttributesForPlainText!
Item was added:
+ ----- Method: Text>>hasAnyAttribute (in category 'testing') -----
+ hasAnyAttribute
+ "Also see (commentary in) #isPlainText, which is compatible with the String \
protocol. + Examples:
+ data isStringOrText and: [data isPlainText].
+ data isString or: [data isText and: [data hasAnyAttribute not]]."
+
+ ^ self notEmpty and: [self runs anySatisfy: [:attributes | attributes notEmpty]]!
Item was added:
+ ----- Method: Text>>hasAttributeThat: (in category 'testing') -----
+ hasAttributeThat: block
+
+ ^ self runs anySatisfy: [:attributes |
+ attributes anySatisfy: [:attribute |
+ block value: attribute]]!
Item was changed:
----- Method: Text>>hasClickableAttribute (in category 'testing') -----
hasClickableAttribute
+ ^ self hasAttributeThat: [:attr | attr mayActOnClick]!
- ^ self runs anySatisfy: [:attrs | attrs anySatisfy: [:attr |
- attr respondsTo: #mayActOnClick]]!
Item was changed:
----- Method: Text>>hasColorAttribute (in category 'testing') -----
hasColorAttribute
+ ^ self hasAttributeThat: [:attr | attr respondsTo: #color]!
- ^ self runs anySatisfy: [:attrs | attrs anySatisfy: [:attr |
- attr respondsTo: #color]]!
Item was changed:
----- Method: Text>>hasFontAttribute (in category 'testing') -----
hasFontAttribute
+ ^ self hasAttributeThat: [:attr |
+ (attr respondsTo: #fontNumber) or: [attr respondsTo: #font]]!
- ^ self runs anySatisfy: [:attrs | attrs anySatisfy: [:attr |
- (attr respondsTo: #fontNumber) or: [attr respondsTo: #font]]]!
Item was added:
+ ----- Method: Text>>isPlainText (in category 'testing') -----
+ isPlainText
+ "A plain text has no attribute that is substantial for a character's visual \
representation. As of now, this excludes text alignment as this is regarded more a \
layout property of the surrounding text container (or widget). See #hasAttributes for \
a more strict check and #asPlainText for conversion. Note that Squeak's notion of \
text attributes is more powerful and expressive compared to what plain-text is \
outside Squeak's context." +
+ self flag: #todo. "mt: First, we should find a way to make widget-specific text \
alignment possible without having to set attributes on the (plain) text it is \
showing. See uses of #plainTextOnly(:). Second, there might be an entire category of \
text attributes possible that only affects Squeak-specific magic but not related to \
the user's notin of plain text. Thus, find a better check." + ^ (self \
hasAttributeThat: [:att | att isTextAlignment not]) not!
Item was added:
+ ----- Method: Text>>removeAttributesForPlainText (in category 'private') -----
+ removeAttributesForPlainText
+ "In the receiver, remove all text attributes so that #isPlainText will answer true \
after this." +
+ self removeAttributesThat: [:att | att isTextAlignment not].!
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic