WO2023078175A1 - 一种文本显示方法、装置、设备及存储介质 - Google Patents

一种文本显示方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2023078175A1
WO2023078175A1 PCT/CN2022/128271 CN2022128271W WO2023078175A1 WO 2023078175 A1 WO2023078175 A1 WO 2023078175A1 CN 2022128271 W CN2022128271 W CN 2022128271W WO 2023078175 A1 WO2023078175 A1 WO 2023078175A1
Authority
WO
WIPO (PCT)
Prior art keywords
container
text
character
input text
length
Prior art date
Application number
PCT/CN2022/128271
Other languages
English (en)
French (fr)
Inventor
汤宏伟
冯威
温俊
Original Assignee
北京字跳网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字跳网络技术有限公司 filed Critical 北京字跳网络技术有限公司
Publication of WO2023078175A1 publication Critical patent/WO2023078175A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Definitions

  • the present disclosure relates to the field of data processing, and in particular to a text display method, device, equipment and storage medium.
  • UI design software when wanting to display a piece of text on a certain control, the designer can manually copy and paste the text into the container corresponding to the control, and manually delete the text beyond the scope of the container. character. Obviously, this manual way of processing text display reduces the work efficiency of designers.
  • the present disclosure provides a text display method, the method comprising:
  • the current width of the first container is smaller than the length of the input text, then determining a target truncated character from the input text; wherein the input text includes a plurality of characters;
  • the determining the length of the input text in the first container and the current width of the first container includes:
  • the length of the input text in the first container and the current width of the first container are determined.
  • the determining the target truncated character from the input text includes:
  • the method further includes:
  • the input text is displayed in the first container.
  • the method further includes:
  • the truncated text displayed in the first container is trimmed.
  • the present disclosure provides a text display device, the device comprising:
  • the first determination module is configured to determine the length of the input text in the first container, and the current width of the first container; wherein, the first container is used to carry the text displayed on the target control;
  • a second determination module configured to determine a target truncated character from the input text when it is determined that the current width of the first container is smaller than the length of the input text; wherein the input text includes a plurality of characters ;
  • a truncation module configured to delete the characters after the target truncation character in the input text, and add a preset symbol at the next position adjacent to the target truncation character, to obtain the truncation corresponding to the input text post text;
  • a display module configured to display the truncated text in the first container.
  • the present disclosure provides a non-transitory computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are run on a terminal device, the terminal device realizes the above-mentioned Methods.
  • the present disclosure provides a device, including: a memory, a processor, and a computer program stored on the memory and operable on the processor, when the processor executes the computer program, Implement the above method.
  • the present disclosure provides a computer program product, where the computer program product includes a computer program/instruction, and when the computer program/instruction is executed by a processor, the above method is implemented.
  • the present disclosure provides a computer program, which implements the above method when the computer program is executed by a processor.
  • FIG. 1 is a schematic diagram of two existing processing methods for displaying text
  • FIG. 2 is a flowchart of a text display method provided by an embodiment of the present disclosure
  • FIG. 3 is a schematic diagram of a method for determining a target truncated character provided by an embodiment of the present disclosure
  • FIG. 4 is a schematic diagram of cutting the truncated text displayed in the first container provided by an embodiment of the present disclosure
  • FIG. 5 is a schematic structural diagram of a text display device provided by an embodiment of the present disclosure.
  • Fig. 6 is a schematic structural diagram of a text display device provided by an embodiment of the present disclosure.
  • an embodiment of the present disclosure provides a text display method, which realizes the function of displaying text on controls in UI design software by automatically truncating characters beyond the scope of the container. While ensuring the text display effect, the work efficiency of designers is improved.
  • FIG. 1 it is a schematic diagram of two existing processing methods for displaying text.
  • the first type when the width of the text box becomes smaller, the text display remains unchanged. Obviously, this text display processing method It cannot meet the needs of design software users, and reduces the software experience of design software users.
  • the second type When the width of the text box becomes smaller, the text displayed in the text box will be displayed in a new line automatically, but the text displayed in the new line will be displayed in the area outside the text box. Obviously, this text display processing method cannot It satisfies the needs of design software users and reduces the software experience of design software users.
  • the embodiment of the present disclosure provides a text display method.
  • the embodiment of the present disclosure realizes the function of displaying text on the control in the UI design software by automatically truncating the characters beyond the range of the container and adding a preset symbol such as "", which improves the display effect of the text while ensuring the text display effect. improve the efficiency of designers.
  • an embodiment of the present disclosure provides a text display method.
  • FIG. 2 it is a flowchart of a text display method provided by an embodiment of the present disclosure. The method includes:
  • S201 Determine the length of the input text in the first container and the current width of the first container.
  • the first container is used to carry the text displayed on the target control.
  • the target control may be a control capable of displaying text in UI design software, for example, the target control may be a control such as a text box or a button.
  • the target control has a corresponding container (hereinafter referred to as the first container), and the first container is used to carry the text displayed on the target control.
  • the first container may be any container in the UI design software.
  • the length of the input text in the first container and the current width of the first container are determined, so as to determine whether there is a pair of the first container by comparing the sizes of the two Truncation requirements for entered text within.
  • the length of the input text in the first container refers to the length from the first character to the last character in the input text in the first container.
  • the width of the first container in the UI design software is adjustable, and the width of the first container can be increased or reduced by pulling the edge of the first container.
  • the input text in the first container is first determined length, and the current width of the first container, and then compare the size of the two to determine whether the input text needs to be truncated.
  • the input text includes a plurality of characters.
  • the size relationship between the two is determined.
  • the current width of the first container is smaller than the length of the input text in the first container, it means that the input text in the first container exceeds the display range of the first container, and the input text in the first container needs to be modified at this time Perform truncation processing.
  • determine the target truncation character from the input text in the first container and then use the target truncation character as a demarcation point to perform truncation processing on the input text.
  • the Nth character in the input text in the first container may be determined as the target truncated character, where N may be a natural number set in advance based on experience.
  • the currently traversed characters are determined by traversing the characters in the input text in the first container. Then, determine the length from the first character in the input text in the first container to the current traversal character as the first length, and determine the first character in the input text in the first container to the current traversal character The length of the next adjacent character of is used as the second length.
  • the current traversable character is determined as Target truncation character.
  • the preset symbol may be a special symbol such as an ellipsis "", which is used to indicate that there is hidden text in the first container that is not displayed.
  • FIG. 3 is a schematic diagram of a method for determining a target truncated character provided by an embodiment of the present disclosure, wherein the input text in the first container is "This is a very, very long Demonstration text", assuming that it traverses forward from the last character "Ben", since the target truncation character is usually located before the last character "Ben”, therefore, first determine the character "Wen” adjacent to "Ben” as the current Traverse the characters, and then determine the length from the first character “this” to the current traversal character "Wen” as the first length W1, and then determine the corresponding length from the first character "this” to the current traversal character "Wen”.
  • the length between the adjacent next character “ ⁇ " is used as the second length W2.
  • the current traversal character can be determined as the target truncation character, otherwise, continue to determine the character "fan” as the current traversal character, continue to determine the character "fan” Whether " is the target truncation character, traverse each character in the first container in turn until the target truncation character is determined.
  • the eighth character "long" in the input text in the first container can be determined as the target truncated character, and then the input text can be truncated based on the target truncated character.
  • S203 Delete the character after the target truncated character in the input text, and add a preset symbol next to the target truncated character to obtain the truncated text corresponding to the input text.
  • the truncated text corresponding to the input text can be obtained.
  • the truncated text is displayed in the first container, so that the text displayed on the control corresponding to the first container will not exceed the display range
  • the effect guarantees the user experience.
  • the display length can be adaptively adjusted, and characters beyond the range of the container can be hidden to ensure the text display effect.
  • the embodiment of the present disclosure replaces the truncated text displayed in the first container with the input text, and at this time, the input text is completely displayed in the first container.
  • the embodiment of the present disclosure first determines whether the height of the truncated text displayed in the first container is greater than that of the first container.
  • the current height of a container that is, the height after adjustment
  • the truncated text displayed in the first container may be trimmed.
  • FIG. 4 it is a schematic diagram of cutting the truncated text displayed in the first container provided by an embodiment of the present disclosure, wherein, by adjusting the height of the container, the truncated text in the first container "this is A long, long" display is out of range, therefore, the embodiment of the present disclosure can automatically cut the truncated text displayed in the first container, as shown in Figure 4, so that the display of the cut text is no longer Beyond the scope of the first container, the user experience of UI design software is improved.
  • the text display method first, determine the length of the input text in the first container and the current width of the first container, if it is determined that the current width of the first container is smaller than the length of the input text, then from Determine the target truncation character in the input text, then delete the character after the target truncation character in the input text, and add a preset symbol next to the target truncation character to obtain the truncated text corresponding to the input text , and then display the truncated text in the first container.
  • the embodiment of the present disclosure realizes the function of displaying text on the control in the UI design software by automatically truncating the characters beyond the range of the container and adding a preset symbol such as "", which improves the display effect of the text while ensuring the text display effect. improve the efficiency of designers.
  • the present disclosure also provides a text display device.
  • FIG. 5 it is a schematic structural diagram of a text display device provided by an embodiment of the present disclosure.
  • the device includes:
  • the first determination module 501 is configured to determine the length of the input text in the first container and the current width of the first container; wherein, the first container is used to carry the text displayed on the target control;
  • the second determination module 502 is configured to determine a target truncated character from the input text when it is determined that the current width of the first container is smaller than the length of the input text; wherein the input text includes a plurality of character;
  • the truncation module 503 is configured to delete the character after the target truncation character in the input text, and add a preset symbol at the next position next to the target truncation character, so as to obtain the corresponding truncation character of the input text. truncated text;
  • a display module 504 configured to display the truncated text in the first container.
  • the first determination module is specifically configured to:
  • the length of the input text in the first container and the current width of the first container are determined.
  • the second determining module includes:
  • the first determining submodule is used to determine the length from the first character in the input text to the currently traversed character as the first length;
  • the second determining submodule is used to determine the length from the first character in the input text to the next adjacent character of the current traversing character as the second length;
  • the third determining submodule is used to determine that the sum of the first length and the width of the preset symbol is not greater than the current width of the first container, and the sum of the second length and the width of the preset symbol If it is larger than the current width of the first container, determine the current traversed character as the target truncated character.
  • the device further includes:
  • the third determining module is configured to traverse forward from the last character of the input text, or traverse backward from the first character of the input text, to determine the current traverse character.
  • the device further includes:
  • a fourth determining module configured to determine whether the current width of the first container is smaller than the length of the input text in response to an adjustment operation on the current width of the first container
  • a replacement module configured to, when it is determined that the current width of the first container is not less than the length of the input text, display the input text on the in the first container.
  • the device further includes:
  • a fifth determination module configured to determine whether the height of the truncated text displayed in the first container is greater than the current height of the first container in response to an adjustment operation on the current height of the first container;
  • a cutting module configured to cut the truncated text displayed in the first container when it is determined that the height of the truncated text is greater than the current height of the first container.
  • the length of the input text in the first container and the current width of the first container are determined, and if it is determined that the current width of the first container is smaller than the length of the input text, then from Determine the target truncation character in the input text, then delete the character after the target truncation character in the input text, and add a preset symbol next to the target truncation character to obtain the truncated text corresponding to the input text , and then display the truncated text in the first container.
  • the embodiment of the present disclosure realizes the function of displaying text on the control in the UI design software by automatically truncating the characters beyond the range of the container and adding a preset symbol such as "", which improves the display effect of the text while ensuring the text display effect. improve the efficiency of designers.
  • an embodiment of the present disclosure also provides a non-transitory computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are run on the terminal device, the The terminal device implements the text display method described in the embodiments of the present disclosure.
  • the embodiment of the present disclosure also provides a computer program product, the computer program product includes a computer program/instruction, and when the computer program/instruction is executed by a processor, the text display method described in the embodiment of the present disclosure is implemented.
  • the embodiment of the present disclosure also provides a computer program, which implements the text display method described in the embodiment of the present disclosure when the computer program is executed by a processor.
  • an embodiment of the present disclosure also provides a text display device, as shown in FIG. 6 , which may include:
  • Processor 601 , memory 602 , input device 603 and output device 604 The number of processors 601 in the text display device may be one or more, and one processor is taken as an example in FIG. 6 .
  • the processor 601 , the memory 602 , the input device 603 and the output device 604 may be connected through a bus or in other ways, wherein connection through a bus is taken as an example in FIG. 6 .
  • the memory 602 can be used to store software programs and modules, and the processor 601 executes various functional applications and data processing of the text display device by running the software programs and modules stored in the memory 602 .
  • the memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function, and the like.
  • the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices.
  • the input device 603 can be used to receive input numbers or character information, and generate signal input related to user settings and function control of the text display device.
  • the processor 601 will load the executable files corresponding to the processes of one or more application programs into the memory 602 according to the following instructions, and the processor 601 will run the executable files stored in the memory 602. Application programs, so as to realize various functions of the above-mentioned text display device.

Abstract

本公开提供了一种文本显示方法、装置、设备及存储介质,所述方法包括:首先,确定第一容器内的已输入文本的长度,以及第一容器的当前宽度,如果确定第一容器的当前宽度小于已输入文本的长度,则从已输入文本中确定目标截断字符,然后,将已输入文本中位于目标截断字符之后的字符进行删除,并在目标截断字符相邻下一个位置添加预设符号,得到已输入文本对应的截断后文本,进而将截断后文本显示于第一容器内。

Description

一种文本显示方法、装置、设备及存储介质
相关申请的交叉引用
本申请要求于2021年11月4日提交的名称为“一种文本显示方法、装置、设备及存储介质”的中国专利申请第202111300804.X号的优先权,该申请的公开通过引用被全部结合于此。
技术领域
本公开涉及数据处理领域,尤其涉及一种文本显示方法、装置、设备及存储介质。
背景技术
用户界面(user Interface;UI)设计软件中,想要将一段文本显示于某个控件上时,可以由设计人员手动将该文本复制粘贴到该控件对应的容器中,并手动删除超出容器范围的字符。显然,这种手动处理文本显示的方式降低了设计人员的工作效率。
发明内容
第一方面,本公开提供了一种文本显示方法,所述方法包括:
确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度;其中,所述第一容器用于承载目标控件上显示的文本;
如果确定所述第一容器的当前宽度小于所述已输入文本的长度,则从所述已输入文本中确定目标截断字符;其中,所述已输入文本包括多个字符;
将所述已输入文本中位于所述目标截断字符之后的字符进行删除,并在所述目标截断字符相邻下一个位置添加预设符号,得到所述已输入文本对应的截断后文本;
将所述截断后文本显示于所述第一容器内。
一种可选的实施方式中,所述确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度,包括:
响应于针对第一容器的当前宽度的调节操作,确定所述第一容器内的已输入文本的长度,以及所述第一容器的当前宽度。
一种可选的实施方式中,所述从所述已输入文本中确定目标截断字符,包括:
确定所述已输入文本中第一个字符到当前遍历字符的长度,作为第一长度;
以及,确定所述已输入文本中第一个字符到所述当前遍历字符的相邻下一个字符的长 度,作为第二长度;
在确定所述第一长度与预设符号的宽度之和不大于所述第一容器的当前宽度,且所述第二长度与所述预设符号的宽度之和大于所述第一容器的当前宽度时,将所述当前遍历字符确定为目标截断字符。
一种可选的实施方式中,所述确定所述已输入文本中第一个字符到当前遍历字符的长度,作为第一长度之前,还包括:
从所述已输入文本的最后一个字符开始向前遍历,或者从所述已输入文本的第一个字符开始向后遍历,确定当前遍历字符。
一种可选的实施方式中,所述将所述截断后文本显示于所述第一容器内之后,还包括:
响应于针对第一容器的当前宽度的调节操作,确定所述第一容器的当前宽度是否小于所述已输入文本的长度;
如果确定所述第一容器的当前宽度不小于所述已输入文本的长度,则利用所述已输入文本替换所述截断后文本后,将所述已输入文本显示于所述第一容器内。
一种可选的实施方式中,所述将所述截断后文本显示于所述第一容器内之后,还包括:
响应于针对所述第一容器的当前高度的调节操作,确定所述第一容器内显示的所述截断后文本的高度是否大于所述第一容器的当前高度;
如果确定所述截断后文本的高度大于所述第一容器的当前高度,则对所述第一容器内显示的所述截断后文本进行裁切。
第二方面,本公开提供了一种文本显示装置,所述装置包括:
第一确定模块,用于确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度;其中,所述第一容器用于承载目标控件上显示的文本;
第二确定模块,用于在确定所述第一容器的当前宽度小于所述已输入文本的长度时,从所述已输入文本中确定目标截断字符;其中,所述已输入文本包括多个字符;
截断模块,用于将所述已输入文本中位于所述目标截断字符之后的字符进行删除,并在所述目标截断字符相邻下一个位置添加预设符号,得到所述已输入文本对应的截断后文本;
显示模块,用于将所述截断后文本显示于所述第一容器内。
第三方面,本公开提供了一种非瞬态的计算机可读存储介质,所述计算机可读存储介质中存储有指令,当所述指令在终端设备上运行时,使得所述终端设备实现上述的方法。
第四方面,本公开提供了一种设备,包括:存储器,处理器,及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现上述的方法。
第五方面,本公开提供了一种计算机程序产品,所述计算机程序产品包括计算机程序/指令,所述计算机程序/指令被处理器执行时实现上述的方法。
第六方面,本公开提供了一种计算机程序,所述计算机程序被处理器执行时实现上述的方法。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。
为了更清楚地说明本公开实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为现有的两种显示文本的处理方式的示意图;
图2为本公开实施例提供的一种文本显示方法的流程图;
图3为本公开实施例提供的一种目标截断字符的确定方法示意图;
图4为本公开实施例提供的一种对第一容器内显示的截断后文本进行裁切的示意图;
图5为本公开实施例提供的一种文本显示装置的结构示意图;
图6为本公开实施例提供的一种文本显示设备的结构示意图。
具体实施方式
为了能够更清楚地理解本公开的上述目的、特征和优点,下面将对本公开的方案进行进一步描述。需要说明的是,在不冲突的情况下,本公开的实施例及实施例中的特征可以相互组合。
在下面的描述中阐述了很多具体细节以便于充分理解本公开,但本公开还可以采用其他不同于在此描述的方式来实施;显然,说明书中的实施例只是本公开的一部分实施例,而不是全部的实施例。
在UI设计软件中,如何实现将文本显示于控件的功能,能够提高设计人员的工作效率,是目前亟需解决的技术问题。
为了解决上述技术问题或者至少部分地解决上述技术问题,本公开实施例提供了一种文本显示方法,通过自动将超出容器范围的字符进行截断,实现UI设计软件中在控件上显示文本的功能,在保证文本显示效果的同时,提高了设计人员的工作效率。
在UI设计软件中,针对超出文本框宽度的显示文本如何处理,一直是亟需解决的技术问题。如图1所示,为现有的两种显示文本的处理方式的示意图,第一种:在文本框的宽度变小的情况下,文本显示情况不变,显然,这种文本显示的处理方式不能满足设计软件用户的使用需求,降低了设计软件用户的软件使用体验。第二种:在文本框的宽度变小的情况下,文本框内显示的文本自动换行显示,但是换行显示的文本显示在文本框之外的区域,显然,这种文本显示的处理方式也不能满足设计软件用户的使用需求,降低了设计软件用户的软件使用体验。
可见,上述的UI设计软件中的文本显示功能不能满足用户的使用需求,为此,本公开实施例提供了一种文本显示方法,首先,确定第一容器内的已输入文本的长度,以及第一容器的当前宽度,如果确定第一容器的当前宽度小于已输入文本的长度,则从已输入文本中确定目标截断字符,然后,将已输入文本中位于目标截断字符之后的字符进行删除,并在目标截断字符相邻下一个位置添加预设符号,得到已输入文本对应的截断后文本,进而将截断后文本显示于第一容器内。本公开实施例通过自动将超出容器范围的字符进行截断,并添加例如为“…”预设符号的方式,实现UI设计软件中在控件上显示文本的功能,在保证文本显示效果的同时,提高了设计人员的工作效率。
基于此,本公开实施例提供了一种文本显示方法,参考图2,为本公开实施例提供的一种文本显示方法的流程图,该方法包括:
S201:确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度。
其中,所述第一容器用于承载目标控件上显示的文本。
目标控件可以为UI设计软件中能够显示文本的控件,例如目标控件可以为文本框、按钮button等控件。在UI设计软件中,目标控件具有对应的容器(以下称为第一容器),第一容器用于承载目标控件上显示的文本。其中,第一容器可以为UI设计软件中的任意一个容器。
本公开实施例中,在第一容器内输入文本之后,确定第一容器内的已输入文本的长度,以及第一容器的当前宽度,以便通过比较二者的大小,确定是否存在对第一容器内的已输 入文本的截断需求。
具体的,第一容器内的已输入文本的长度,是指第一容器内的已输入文本中从第一个字符到最后一个字符的长度。
实际应用中,UI设计软件中的第一容器的宽度是可调节的,通过拉动第一容器的边缘,可以增加或缩小第一容器的宽度。
一种可选的实施方式中,当接收到针对第一容器的当前宽度的调节操作时,例如,将第一容器的当前宽度由大向小调节时,首先确定第一容器内的已输入文本的长度,以及第一容器的当前宽度,后续通过二者大小的比较,确定是否需要对已输入文本进行截断。
S202:如果确定所述第一容器的当前宽度小于所述已输入文本的长度,则从所述已输入文本中确定目标截断字符。
其中,所述已输入文本包括多个字符。
本公开实施例中,在确定第一容器内的已输入文本的长度,以及第一容器的当前宽度之后,判断二者的大小关系。当确定第一容器的当前宽度小于第一容器内的已输入文本的长度时,说明第一容器内的已输入文本超出第一容器的显示范围,此时需要对第一容器内的已输入文本进行截断处理,为此,从第一容器内的已输入文本中确定目标截断字符,后续以目标截断字符为分界点,对已输入文本进行截断处理。
一种可选的实施方式中,可以将第一容器内的已输入文本中的第N个字符确定为目标截断字符,其中,N可以为预先基于经验设置的自然数。
另一种可选的实施方式中,通过对第一容器内的已输入文本中的字符的遍历,确定当前遍历字符。然后,确定第一容器内的已输入文本中第一个字符到该当前遍历字符的长度,作为第一长度,以及确定第一容器内的已输入文本中的第一个字符到该当前遍历字符的相邻下一个字符的长度,作为第二长度。在确定第一长度与预设符号的宽度之和不大于第一容器的当前宽度,且第二长度与预设符号的宽度之和大于第一容器的当前宽度时,将该当前遍历字符确定为目标截断字符。其中,预设符号可以为省略号“…”等特殊符号,用于表征第一容器内存在隐藏的文本未被显示。
一种可选的实施方式中,可以从第一容器内的已输入文本的最后一个字符开始向前遍历,依次将各个字符确定为当前遍历字符,直到从已输入文本中确定出目标截断字符。
另一种可选的实施方式中,还可以从第一容器内的已输入文本的第一个字符开始向后遍历,依次将各个字符确定为当前遍历字符,直到从已输入文本中确定出目标截断字符。
为了便于对上述实施方式的理解,参考图3,为本公开实施例提供的一种目标截断字符的确定方法示意图,其中,第一容器内的已输入文本为“这是一段很长很长的示范文本”,假设从最后一个字符“本”开始向前遍历,由于目标截断字符通常位于最后一个字符“本”之前,因此,首先将“本”的相邻前一个字符“文”确定为当前遍历字符,然后确定从第一个字符“这”到当前遍历字符“文”之间的长度,作为第一长度W1,进而确定从第一个字符“这”到当前遍历字符“文”的相邻下一个字符“本”之间的长度,作为第二长度W2。计算第一长度W1与预设符号“…”的宽度W之和,以及第二长度W2与预设符号“…”的宽度W之和,然后确定W1+W与第一容器的当前宽度W0的大小关系,以及确定W2+W与W0的大小关系。如果确定W1+W<=W0,且W2+W>W0,则可以将当前遍历字符确定为目标截断字符,否则,继续将字符“范”确定为当前遍历字符,依照上述方式继续确定字符“范”是否为目标截断字符,依次遍历第一容器内的各个字符,直到确定出目标截断字符为止。
如图3所示,基于上述方式可以将第一容器内的已输入文本中的第八个字符“长”确定为目标截断字符,后续可以基于目标截断字符实现对已输入文本的截断处理。
S203:将所述已输入文本中位于所述目标截断字符之后的字符进行删除,并在所述目标截断字符相邻下一个位置添加预设符号,得到所述已输入文本对应的截断后文本。
本公开实施例中,在确定已输入文本中的目标截断字符之后,将已输入文本中位于目标截断字符之后的字符进行删除,然后,在删除字符之后,在目标截断字符相邻下一个位置添加预设符号,例如省略号“…”,以表征第一容器中存在隐藏未显示的字符。基于上述方式可以得到已输入文本对应的截断后文本。
参考上述图3,在确定已输入文本“这是一段很长很长的示范文本”中的第八个字符“长”为目标截断字符之后,将“长”之后的字符删除,删除字符之后的已输入文本为“这是一段很长很长”,此时,为了表征存在隐藏未显示的字符,可以在目标截断字符“长”之后添加预设符号,得到如图3所示的截断后文本“这是一段很长很长…”。
S204:将所述截断后文本显示于所述第一容器内。
本公开实施例中,在确定第一容器内已输入文本对应的截断后文本之后,将截断后文本显示于第一容器内,使得第一容器对应的控件上显示的文本不会存在显示超范围的效果,保证了用户的体验。
本公开实施例中,同一段文本在不同尺寸的容器中显示时,能够自适应的调整显示长度,将超出容器范围的字符隐藏,保证了文本显示效果。
一种可选的实施方式中,在第一容器内显示截断后文本的情况下,如果接收到针对第一容器的当前宽度的调节操作,首先确定第一容器的当前宽度是否小于已输入文本的长度,如果确定第一容器的当前宽度不小于已输入文本的长度,则说明用户将第一容器的当前宽度由小向大调节,此时需要将隐藏未显示的字符重新在第一容器内进行显示,为此,本公开实施例利用已输入文本替换第一容器内显示的截断后文本,此时在第一容器内完整显示已输入文本。
在UI设计软件的使用过程中,不仅支持对第一容器的宽度进行调节,也支持对第一容器的高度进行调节,一旦将第一容器的高度由大向小调节,则可能出现第一容器内显示的文本超出第一容器范围的情况,为此,本公开实施例在接收到针对第一容器的当前高度的调节操作时,首先确定第一容器内显示的截断后文本的高度是否大于第一容器的当前高度(即调节后高度),如果确定截断后文本的高度大于第一容器的当前高度,则可以对第一容器内显示的截断后文本进行裁切。
如图4所示,为本公开实施例提供的一种对第一容器内显示的截断后文本进行裁切的示意图,其中,通过调节容器的高度使得第一容器内的截断后文本“这是一段很长很长…”的显示超出范围,因此,本公开实施例可以对第一容器内显示的截断后文本进行自动裁切,如图4所示,使得裁切后的文本的显示不再超出第一容器的范围,提升了用户对UI设计软件的使用体验。
本公开实施例提供的文本显示方法中,首先,确定第一容器内的已输入文本的长度,以及第一容器的当前宽度,如果确定第一容器的当前宽度小于已输入文本的长度,则从已输入文本中确定目标截断字符,然后,将已输入文本中位于目标截断字符之后的字符进行删除,并在目标截断字符相邻下一个位置添加预设符号,得到已输入文本对应的截断后文本,进而将截断后文本显示于第一容器内。本公开实施例通过自动将超出容器范围的字符进行截断,并添加例如为“…”预设符号的方式,实现UI设计软件中在控件上显示文本的功能,在保证文本显示效果的同时,提高了设计人员的工作效率。
基于上述方法实施例,本公开还提供了一种文本显示装置,参考图5,为本公开实施例提供的一种文本显示装置的结构示意图,所述装置包括:
第一确定模块501,用于确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度;其中,所述第一容器用于承载目标控件上显示的文本;
第二确定模块502,用于在确定所述第一容器的当前宽度小于所述已输入文本的长度时,从所述已输入文本中确定目标截断字符;其中,所述已输入文本包括多个字符;
截断模块503,用于将所述已输入文本中位于所述目标截断字符之后的字符进行删除,并在所述目标截断字符相邻下一个位置添加预设符号,得到所述已输入文本对应的截断后文本;
显示模块504,用于将所述截断后文本显示于所述第一容器内。
一种可选的实施方式中,所述第一确定模块,具体用于:
响应于针对第一容器的当前宽度的调节操作,确定所述第一容器内的已输入文本的长度,以及所述第一容器的当前宽度。
一种可选的实施方式中,所述第二确定模块,包括:
第一确定子模块,用于确定所述已输入文本中第一个字符到当前遍历字符的长度,作为第一长度;
第二确定子模块,用于确定所述已输入文本中第一个字符到所述当前遍历字符的相邻下一个字符的长度,作为第二长度;
第三确定子模块,用于在确定所述第一长度与预设符号的宽度之和不大于所述第一容器的当前宽度,且所述第二长度与所述预设符号的宽度之和大于所述第一容器的当前宽度时,将所述当前遍历字符确定为目标截断字符。
一种可选的实施方式中,所述装置还包括:
第三确定模块,用于从所述已输入文本的最后一个字符开始向前遍历,或者从所述已输入文本的第一个字符开始向后遍历,确定当前遍历字符。
一种可选的实施方式中,所述装置还包括:
第四确定模块,用于响应于针对第一容器的当前宽度的调节操作,确定所述第一容器的当前宽度是否小于所述已输入文本的长度;
替换模块,用于在确定所述第一容器的当前宽度不小于所述已输入文本的长度时,利用所述已输入文本替换所述截断后文本后,将所述已输入文本显示于所述第一容器内。
一种可选的实施方式中,所述装置还包括:
第五确定模块,用于响应于针对所述第一容器的当前高度的调节操作,确定所述第一容器内显示的所述截断后文本的高度是否大于所述第一容器的当前高度;
裁切模块,用于在确定所述截断后文本的高度大于所述第一容器的当前高度时,对所 述第一容器内显示的所述截断后文本进行裁切。
本公开实施例提供的文本显示装置中,首先,确定第一容器内的已输入文本的长度,以及第一容器的当前宽度,如果确定第一容器的当前宽度小于已输入文本的长度,则从已输入文本中确定目标截断字符,然后,将已输入文本中位于目标截断字符之后的字符进行删除,并在目标截断字符相邻下一个位置添加预设符号,得到已输入文本对应的截断后文本,进而将截断后文本显示于第一容器内。本公开实施例通过自动将超出容器范围的字符进行截断,并添加例如为“…”预设符号的方式,实现UI设计软件中在控件上显示文本的功能,在保证文本显示效果的同时,提高了设计人员的工作效率。
除了上述方法和装置以外,本公开实施例还提供了一种非瞬态的计算机可读存储介质,计算机可读存储介质中存储有指令,当所述指令在终端设备上运行时,使得所述终端设备实现本公开实施例所述的文本显示方法。
本公开实施例还提供了一种计算机程序产品,所述计算机程序产品包括计算机程序/指令,所述计算机程序/指令被处理器执行时实现本公开实施例所述的文本显示方法。
本公开实施例还提供了一种计算机程序,所述计算机程序被处理器执行时实现本公开实施例所述的文本显示方法。
另外,本公开实施例还提供了一种文本显示设备,参见图6所示,可以包括:
处理器601、存储器602、输入装置603和输出装置604。文本显示设备中的处理器601的数量可以一个或多个,图6中以一个处理器为例。在本公开的一些实施例中,处理器601、存储器602、输入装置603和输出装置604可通过总线或其它方式连接,其中,图6中以通过总线连接为例。
存储器602可用于存储软件程序以及模块,处理器601通过运行存储在存储器602的软件程序以及模块,从而执行文本显示设备的各种功能应用以及数据处理。存储器602可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等。此外,存储器602可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。输入装置603可用于接收输入的数字或字符信息,以及产生与文本显示设备的用户设置以及功能控制有关的信号输入。
具体在本实施例中,处理器601会按照如下的指令,将一个或一个以上的应用程序的进程对应的可执行文件加载到存储器602中,并由处理器601来运行存储在存储器602中的应用程序,从而实现上述文本显示设备的各种功能。
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
以上所述仅是本公开的具体实施方式,使本领域技术人员能够理解或实现本公开。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本公开的精神或范围的情况下,在其它实施例中实现。因此,本公开将不会被限制于本文所述的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。

Claims (11)

  1. 一种文本显示方法,所述方法包括:
    确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度;其中,所述第一容器用于承载目标控件上显示的文本;
    如果确定所述第一容器的当前宽度小于所述已输入文本的长度,则从所述已输入文本中确定目标截断字符;其中,所述已输入文本包括多个字符;
    将所述已输入文本中位于所述目标截断字符之后的字符进行删除,并在所述目标截断字符相邻下一个位置添加预设符号,得到所述已输入文本对应的截断后文本;
    将所述截断后文本显示于所述第一容器内。
  2. 根据权利要求1所述的方法,其中,所述确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度,包括:
    响应于针对第一容器的当前宽度的调节操作,确定所述第一容器内的已输入文本的长度,以及所述第一容器的当前宽度。
  3. 根据权利要求1所述的方法,其中,所述从所述已输入文本中确定目标截断字符,包括:
    确定所述已输入文本中第一个字符到当前遍历字符的长度,作为第一长度;
    以及,确定所述已输入文本中第一个字符到所述当前遍历字符的相邻下一个字符的长度,作为第二长度;
    在确定所述第一长度与预设符号的宽度之和不大于所述第一容器的当前宽度,且所述第二长度与所述预设符号的宽度之和大于所述第一容器的当前宽度时,将所述当前遍历字符确定为目标截断字符。
  4. 根据权利要求3所述的方法,其中,所述确定所述已输入文本中第一个字符到当前遍历字符的长度,作为第一长度之前,还包括:
    从所述已输入文本的最后一个字符开始向前遍历,或者从所述已输入文本的第一个字符开始向后遍历,确定当前遍历字符。
  5. 根据权利要求1所述的方法,其中,所述将所述截断后文本显示于所述第一容器内之后,还包括:
    响应于针对第一容器的当前宽度的调节操作,确定所述第一容器的当前宽度是否小于 所述已输入文本的长度;
    如果确定所述第一容器的当前宽度不小于所述已输入文本的长度,则利用所述已输入文本替换所述截断后文本后,将所述已输入文本显示于所述第一容器内。
  6. 根据权利要求1所述的方法,其中,所述将所述截断后文本显示于所述第一容器内之后,还包括:
    响应于针对所述第一容器的当前高度的调节操作,确定所述第一容器内显示的所述截断后文本的高度是否大于所述第一容器的当前高度;
    如果确定所述截断后文本的高度大于所述第一容器的当前高度,则对所述第一容器内显示的所述截断后文本进行裁切。
  7. 一种文本显示装置,所述装置包括:
    第一确定模块,用于确定第一容器内的已输入文本的长度,以及所述第一容器的当前宽度;其中,所述第一容器用于承载目标控件上显示的文本;
    第二确定模块,用于在确定所述第一容器的当前宽度小于所述已输入文本的长度时,从所述已输入文本中确定目标截断字符;其中,所述已输入文本包括多个字符;
    截断模块,用于将所述已输入文本中位于所述目标截断字符之后的字符进行删除,并在所述目标截断字符相邻下一个位置添加预设符号,得到所述已输入文本对应的截断后文本;
    显示模块,用于将所述截断后文本显示于所述第一容器内。
  8. 一种非瞬态的计算机可读存储介质,所述计算机可读存储介质中存储有指令,当所述指令在终端设备上运行时,使得所述终端设备实现如权利要求1-6中任一项所述的方法。
  9. 一种设备,包括:存储器,处理器,及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现如权利要求1-6中任一项所述的方法。
  10. 一种计算机程序产品,所述计算机程序产品包括计算机程序/指令,所述计算机程序/指令被处理器执行时实现如权利要求1-6中任一项所述的方法。
  11. 一种计算机程序,所述计算机程序被处理器执行时实现如权利要求1-6中任一项所述的方法。
PCT/CN2022/128271 2021-11-04 2022-10-28 一种文本显示方法、装置、设备及存储介质 WO2023078175A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111300804.X 2021-11-04
CN202111300804.XA CN116069420A (zh) 2021-11-04 2021-11-04 一种文本显示方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2023078175A1 true WO2023078175A1 (zh) 2023-05-11

Family

ID=86175711

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/128271 WO2023078175A1 (zh) 2021-11-04 2022-10-28 一种文本显示方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN116069420A (zh)
WO (1) WO2023078175A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102708774A (zh) * 2012-04-19 2012-10-03 广东威创视讯科技股份有限公司 字符串显示方法和系统
US20130156322A1 (en) * 2011-12-15 2013-06-20 Al YAROS Identifying truncated character strings
CN105897875A (zh) * 2016-04-01 2016-08-24 乐视控股(北京)有限公司 文本截断、上传方法和装置
CN111400998A (zh) * 2020-03-09 2020-07-10 北京字节跳动网络技术有限公司 一种文本的显示方法、装置、电子设备及可读存储介质
CN113408241A (zh) * 2021-07-16 2021-09-17 网易(杭州)网络有限公司 文本数据的处理方法、装置、电子设备及可读介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130156322A1 (en) * 2011-12-15 2013-06-20 Al YAROS Identifying truncated character strings
CN102708774A (zh) * 2012-04-19 2012-10-03 广东威创视讯科技股份有限公司 字符串显示方法和系统
CN105897875A (zh) * 2016-04-01 2016-08-24 乐视控股(北京)有限公司 文本截断、上传方法和装置
CN111400998A (zh) * 2020-03-09 2020-07-10 北京字节跳动网络技术有限公司 一种文本的显示方法、装置、电子设备及可读存储介质
CN113408241A (zh) * 2021-07-16 2021-09-17 网易(杭州)网络有限公司 文本数据的处理方法、装置、电子设备及可读介质

Also Published As

Publication number Publication date
CN116069420A (zh) 2023-05-05

Similar Documents

Publication Publication Date Title
BRPI0506116B1 (pt) Method for providing functionality for a selected object through an improved user interface
AU2011299450B2 (en) Concurrent editing of online drawings
US20100313126A1 (en) Method and apparatus for providing selection area for touch interface
US8949729B2 (en) Enhanced copy and paste between applications
JP2012089129A (ja) スクリーンデータ操作方法
US20120210206A1 (en) Resizing an editable area in a web page
CA2133874C (en) Method and system for automatic formatting of user selected text
US8589493B2 (en) Sending related information to indirect email recipients
US9927968B2 (en) Move of object between pages of editable document
KR101638725B1 (ko) 애플리케이션의 문자를 조절하는 방법, 장치, 단말기, 프로그램 및 기록매체
CN106033407B (zh) 一种数据粘贴方法及装置
US20150058708A1 (en) Systems and methods of character dialog generation
US9754350B2 (en) Systems and methods of automatic image sizing
WO2015096598A1 (zh) 页面内容选取方法及系统
WO2023078175A1 (zh) 一种文本显示方法、装置、设备及存储介质
WO2019062175A1 (zh) 信息输入方法及装置
WO2020000812A1 (zh) Ppt文档的生成方法及装置、存储介质、计算机设备
WO2020057357A1 (zh) 文本处理方法、终端以及计算机可读存储介质
US20180024978A1 (en) Approach For Processing Electronic Documents Using Parsing Templates
US20150089356A1 (en) Text Selection
WO2022111406A1 (zh) 控件显示方法、装置和电子设备
CN113988008A (zh) 一种文档对象尺寸调整方法、装置、电子设备及存储介质
AU2015204414A1 (en) Document and object manipulation
CN112784526A (zh) 一种文档页面调整方法及装置
WO2017011680A1 (en) Device and method for processing data

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22889200

Country of ref document: EP

Kind code of ref document: A1