/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the given character, placing it in the correct group according to its Unicode /// category. /// </summary> /// <param name="chr">The character, which can consist of a base character as well as /// possibly some combining characters (diacritics, etc.).</param> /// <param name="type">Type of character being added, if known (really only needed for /// not-yet-defined PUA characters)</param> /// <param name="sortAfterAdd">Inidicates whether or not to sort the list after /// the characters is added.</param> /// <returns>A enumeration value indicating which type of character was added</returns> /// ------------------------------------------------------------------------------------ public ValidCharacterType AddCharacter(string chr, ValidCharacterType type, bool sortAfterAdd) { if (string.IsNullOrEmpty(chr) || IsValid(chr)) { return(ValidCharacterType.None); } int codepoint = chr[0]; if (type == ValidCharacterType.DefinedUnknown) { type = GetNaturalCharType(codepoint); } List <string> list; switch (type) { case ValidCharacterType.WordForming: list = m_WordFormingCharacters; break; case ValidCharacterType.Numeric: list = m_NumericCharacters; break; default: list = m_OtherCharacters; break; } list.Add(chr); if (sortAfterAdd) { Sort(list); } return(type); }
public void GetNaturalCharType(int codepoint, ValidCharacterType type) { CoreWritingSystemDefinition ws = m_wsManager.Create("en-US"); ValidCharacters validChars = ValidCharacters.Load(ws); Assert.AreEqual(type, ReflectionHelper.GetResult(validChars, "GetNaturalCharType", codepoint)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Removes the characters in the specified list from the list of valid characters. /// The return value is a bitmask value indicating from what lists characters were /// removed. /// </summary> /// ------------------------------------------------------------------------------------ public ValidCharacterType RemoveCharacters(List <string> characters) { ValidCharacterType removedTypes = ValidCharacterType.None; if (characters != null) { foreach (string chr in characters) { removedTypes |= RemoveCharacter(chr); } } return(removedTypes); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the characters from the given list, placing each character in the correct /// group according to its Unicode category. /// </summary> /// <param name="characters">The list of characters.</param> /// <returns>A bit-mask value indicating which types of characters were added</returns> /// ------------------------------------------------------------------------------------ public ValidCharacterType AddCharacters(List <string> characters) { ValidCharacterType addedTypes = ValidCharacterType.None; if (characters != null) { foreach (string chr in characters) { addedTypes |= AddCharacter(chr, ValidCharacterType.DefinedUnknown, false); } } SortLists(); return(addedTypes); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the given character, placing it in the correct group according to its Unicode /// category. The list to which the character is added is sorted after the character /// is added. /// </summary> /// <param name="chr">The character, which can consist of a base character as well as /// possibly some combining characters (diacritics, etc.).</param> /// <param name="type">Type of character being added, if known (really only needed for /// not-yet-defined PUA characters)</param> /// <returns>A enumeration value indicating which type of character was added</returns> /// ------------------------------------------------------------------------------------ public ValidCharacterType AddCharacter(string chr, ValidCharacterType type) { return(AddCharacter(chr, type, true)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the given character, placing it in the correct group according to its Unicode /// category. /// </summary> /// <param name="chr">The character, which can consist of a base character as well as /// possibly some combining characters (diacritics, etc.).</param> /// <param name="type">Type of character being added, if known (really only needed for /// not-yet-defined PUA characters)</param> /// <param name="sortAfterAdd">Inidicates whether or not to sort the list after /// the characters is added.</param> /// <returns>A enumeration value indicating which type of character was added</returns> /// ------------------------------------------------------------------------------------ public ValidCharacterType AddCharacter(string chr, ValidCharacterType type, bool sortAfterAdd) { if (string.IsNullOrEmpty(chr) || IsValid(chr)) return ValidCharacterType.None; int codepoint = chr[0]; if (type == ValidCharacterType.DefinedUnknown) type = GetNaturalCharType(codepoint); List<string> list; switch(type) { case ValidCharacterType.WordForming: list = m_WordFormingCharacters; break; case ValidCharacterType.Numeric: list = m_NumericCharacters; break; default: list = m_OtherCharacters; break; } list.Add(chr); if (sortAfterAdd) Sort(list); return type; }
/// --------------------------------------------------------------------------------- /// <summary> /// Adds the specified valid character to one of the valid character grids. /// </summary> /// --------------------------------------------------------------------------------- private void RefreshCharacterGrids(ValidCharacterType type) { if ((type & ValidCharacterType.WordForming) != 0) { m_gridWordForming.RemoveAllCharacters(); m_gridWordForming.AddCharacters(m_validChars.WordFormingCharacters, m_ws); } if ((type & ValidCharacterType.Numeric) != 0) { m_gridNumbers.RemoveAllCharacters(); m_gridNumbers.AddCharacters(m_validChars.NumericCharacters, m_ws); } if ((type & ValidCharacterType.Other) != 0) { m_gridOther.RemoveAllCharacters(); m_gridOther.AddCharacters(m_validChars.OtherCharacters, m_ws); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the given character, placing it in the correct group according to its Unicode /// category. The list to which the character is added is sorted after the character /// is added. /// </summary> /// <param name="chr">The character, which can consist of a base character as well as /// possibly some combining characters (diacritics, etc.).</param> /// <param name="type">Type of character being added, if known (really only needed for /// not-yet-defined PUA characters)</param> /// <returns>A enumeration value indicating which type of character was added</returns> /// ------------------------------------------------------------------------------------ public ValidCharacterType AddCharacter(string chr, ValidCharacterType type) { return AddCharacter(chr, type, true); }
/// --------------------------------------------------------------------------------- /// <summary> /// Adds the specified character to the list of valid characters. /// </summary> /// --------------------------------------------------------------------------------- protected internal virtual void AddCharacter(string chr, ValidCharacterType type, bool makeReceivingGridCurrent) { ValidCharacterType retType = m_validChars.AddCharacter(chr, type); RefreshCharacterGrids(retType); if (makeReceivingGridCurrent || CurrentGrid == null) { switch (retType) { case ValidCharacterType.WordForming: CurrentGrid = m_gridWordForming; break; case ValidCharacterType.Numeric: CurrentGrid = m_gridNumbers; break; case ValidCharacterType.Other: CurrentGrid = m_gridOther; break; default: return; } CurrentGrid.CurrentCharacter = chr; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the character to a list (rather than to a grid). /// </summary> /// ------------------------------------------------------------------------------------ protected internal override void AddCharacter(string chr, ValidCharacterType type, bool notUsed) { m_charsInGrid.Add(chr); }
private void AddCharactersFromWritingSystem(CoreWritingSystemDefinition ws, string charSetType, ValidCharacterType validCharType) { CharacterSetDefinition charSet; if (!ws.CharacterSets.TryGet(charSetType, out charSet)) { return; } foreach (string chr in charSet.Characters) { AddCharacter(chr, validCharType); } }
private void AddCharactersFromWritingSystem(CoreWritingSystemDefinition ws, string charSetType, ValidCharacterType validCharType, List <string> invalidChars) { CharacterSetDefinition charSet; if (!ws.CharacterSets.TryGet(charSetType, out charSet)) { return; } foreach (string chr in charSet.Characters) { if (TsStringUtils.IsValidChar(chr)) { AddCharacter(chr, validCharType); } else { invalidChars.Add(chr); } } }