WO2016101833A1 - 字符串的显示方法和装置 - Google Patents

字符串的显示方法和装置 Download PDF

Info

Publication number
WO2016101833A1
WO2016101833A1 PCT/CN2015/097655 CN2015097655W WO2016101833A1 WO 2016101833 A1 WO2016101833 A1 WO 2016101833A1 CN 2015097655 W CN2015097655 W CN 2015097655W WO 2016101833 A1 WO2016101833 A1 WO 2016101833A1
Authority
WO
WIPO (PCT)
Prior art keywords
width
character string
character
display
string
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2015/097655
Other languages
English (en)
French (fr)
Inventor
诸炜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Publication of WO2016101833A1 publication Critical patent/WO2016101833A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0481Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing

Definitions

  • the present application relates to the field of data processing technologies, and in particular, to a method and an apparatus for displaying a character string.
  • the display interface of an electronic device has a width limit.
  • the character string to be displayed is long, it is limited by the display width of the electronic device, and the character string cannot be displayed in a single line.
  • the maximum number of characters displayed in a single line can be preset by the user.
  • the character string is long, the characters exceeding the maximum number of characters are directly removed.
  • this approach requires human intervention and is less flexible.
  • the present application aims to solve at least one of the technical problems in the related art to some extent.
  • an object of the present application is to propose a display method of a character string, which can provide human intervention when displaying a character string and can improve flexibility.
  • Another object of the present application is to provide a display device for a character string.
  • a method for displaying a character string includes: acquiring a first width, the first width is a width of a current display area, and acquiring a second width, where the second width is The string to be displayed displays a desired width in a single line; if the second width is greater than the first width, the character string is intercepted such that the display width of the truncated character string is less than or equal to the first width And splicing the intercepted character string; displaying the stitched string.
  • the method for displaying a character string according to the embodiment of the first aspect of the present invention by acquiring the first width and the second width, and intercepting the spliced character string according to the first width and the second width, can be adaptive according to the width of the current display area.
  • the character string is intercepted, thereby improving the flexibility of the string display, and the embodiment does not need to manually set the information, and does not require human intervention, thereby reducing user overhead.
  • a display device for a character string includes: a first acquiring module, configured to acquire a first width, where the first width is a width of a current display area; and a second acquiring module For obtaining a second width, the second width is a width required for displaying a single line of a string to be displayed; and an intercepting module, configured to perform the character string if the second width is greater than the first width Intercepting, so that the display width of the truncated character string is less than or equal to the first width, and splicing the intercepted character string; the display module is configured to display the stitched character string.
  • the display device of the character string according to the embodiment of the second aspect of the present invention can realize adaptively according to the width of the current display area by acquiring the first width and the second width and intercepting the spliced character string according to the first width and the second width.
  • the character string is intercepted, thereby improving the flexibility of the string display, and the embodiment does not need to manually set the information, and does not require human intervention, thereby reducing user overhead.
  • FIG. 1 is a schematic flowchart of a method for displaying a character string according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for displaying a character string according to another embodiment of the present application
  • FIG. 3 is a schematic diagram showing the display of a file name in a display area in the embodiment of the present application.
  • FIG. 4 is a schematic diagram showing the display of a file name in another display area in the embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of a display device for character strings according to another embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a display device for character strings according to another embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a method for displaying a character string according to an embodiment of the present application, where the method includes:
  • S11 Acquire a first width, where the first width is a width of a current display area.
  • the method of this embodiment can be executed by a plug-in, for example, a plug-in loaded in a browser.
  • Plugins can be written in javascript.
  • the width of the current display area can be obtained through the offsetwidth method of javascript.
  • S12 Acquire a second width, which is a width required for displaying a single line of the string to be displayed.
  • the document.defaultView.getComputedStyle method can be used to obtain the Cascading Style Sheets (css) style currently applied by the string; and then dynamically create an empty Document Object Model (dom).
  • the string to be displayed can be a file name.
  • the suffix and the prefix of the string may be intercepted, and then the prefix and the suffix are spliced.
  • the intercepting the suffix and the prefix of the string includes:
  • the prefix of the string is intercepted according to the display width of the prefix.
  • the pre-configured rules include: a suffix including a file type portion of the file name, a preset number of characters of the file name selected from the end character to the front, and an ellipsis ( ).
  • the intercepted suffixes include .jpg, N characters at the back of the file name, N configurable, N greater than or equal to 0, and an ellipsis defined.
  • the display width required for the suffix can be obtained, and after the display width of the suffix is subtracted from the first width, a difference is obtained, and the difference is determined as the display width of the prefix.
  • Each character is sequentially selected from the beginning to the end of the character string until the display width of the character string composed from the start character to the currently selected character is less than or equal to the display width of the prefix, and a display width of a character string consisting of the next character from the start character to the currently selected character is greater than a display width of the prefix; a character string consisting of the start character to the currently selected character is determined as The prefix.
  • the n-th character is selected from the first of the file names as an example, wherein the display width from the first character to the n-th character is less than or equal to A, from the first The display width of the character to the n+1th character is greater than A.
  • intercepted prefix and suffix are directly combined to obtain a spliced string.
  • a string of the file name _1...file name_2. file type can be displayed, wherein the file name_1 and the file name_2 respectively include the front and back characters of the file name.
  • the character string of this embodiment may include one or more of Chinese, English, and numbers.
  • the interception string can be adaptively adapted according to the width of the current display area, thereby improving the flexibility of the string display.
  • the embodiment does not need to manually set information, and does not require human intervention, thereby reducing user overhead.
  • FIG. 2 is a schematic flowchart of a method for displaying a character string according to another embodiment of the present application.
  • the name is an example, and the method includes:
  • S21 Acquire a first width, which is a width of a current display area, and a second width, which is a width required for displaying a file list line to be displayed.
  • the width of the current display area can be obtained by the offsetwidth method of javascript.
  • css Cascading Style Sheets
  • dom Document Object Model
  • the content included in the suffix may be preset, and the suffix is first intercepted according to the preset information, and the prefix is intercepted according to the remaining displayable width after the suffix is intercepted.
  • the suffix is first intercepted according to the preset information, and the prefix is intercepted according to the remaining displayable width after the suffix is intercepted.
  • FIG. 3 For example, referring to FIG. 3, three file names are displayed, wherein the full width of the single line display of the second and third file names is larger than the width of the display area, and the second and third file names can be performed at this time. Intercept and splicing to obtain the spliced file name as shown in FIG.
  • the first file name is displayed directly.
  • the method may further include:
  • the event can be sensed according to gravity, and when the mobile device is sensed to flip, the current display area change can be detected.
  • the gravity sensing event is, for example, sensing that the mobile device is flipped 90 degrees to the right or left.
  • the file name can be intercepted and spliced again.
  • the second file list line is all displayed, and the prefix portion of the third file name is relative to the figure. 2 will show more.
  • the displayed file name adaptive display area can be realized, and the flexibility can be improved without manual intervention; the embodiment is based on the width of the display area and the width of the file name.
  • the interception can be applied to the case where the character string is English and Chinese; in this embodiment, the display content of the file name can be changed according to the change of the display area.
  • FIG. 5 is a schematic structural diagram of a display device for character strings according to another embodiment of the present disclosure.
  • the device 50 includes a first obtaining module 51, a second obtaining module 52, an intercepting module 53 and a display module 54.
  • the first obtaining module 51 is configured to acquire a first width, where the first width is a width of a current display area;
  • the width of the current display area can be obtained through the offsetwidth method of javascript.
  • the second obtaining module 52 is configured to obtain a second width, where the second width is a width required for displaying a single line of the character string to be displayed;
  • the document.defaultView.getComputedStyle method can be used to obtain the Cascading Style Sheets (css) style currently applied by the string; and then dynamically create an empty Document Object Model (dom).
  • the string to be displayed can be a file name.
  • the intercepting module 53 is configured to intercept the character string if the second width is greater than the first width, so that a display width of the intercepted character string is less than or equal to the first width, and the intercepted character String stitching;
  • the intercepting module 53 includes:
  • a first unit 531 configured to intercept a suffix and a prefix of the string
  • the second unit 532 is configured to splicing the suffix and the prefix to obtain the spliced character string.
  • the first unit 531 is specifically configured to:
  • the prefix of the string is intercepted according to the display width of the prefix.
  • the display width of the prefix is a difference between the first width and the display width of the suffix
  • the first unit 531 is specifically configured to:
  • Each character is sequentially selected from the beginning to the end of the character string until the display width of the character string composed from the start character to the currently selected character is less than or equal to the display width of the prefix, and a display width of a character string consisting of the start character and a next character of the currently selected character is greater than a display width of the prefix;
  • a character string consisting of the start character to the currently selected character is determined as the prefix.
  • the intercepted suffixes include .jpg, N characters at the back of the file name, N configurable, N greater than or equal to 0, and an ellipsis defined.
  • the display width required for the suffix can be obtained, and after the display width of the suffix is subtracted from the first width, a difference is obtained, and the difference is determined as the display width of the prefix.
  • the nth character is selected as an example, wherein, from the first The display width from the characters to the nth character is less than or equal to A, and the display width from the first character to the n+1th character is greater than A.
  • the display module 54 is configured to display the stitched string.
  • intercepted prefix and suffix are directly combined to obtain a spliced string.
  • a string of the file name _1...file name_2. file type can be displayed, wherein the file name_1 and the file name_2 respectively include the front and back characters of the file name.
  • the character string of this embodiment may include one or more of Chinese, English, and numbers.
  • the apparatus 50 further includes:
  • a detecting module 55 configured to detect that the current display area is changed
  • the event can be sensed according to gravity, and when the mobile device is sensed to flip, the current display area change can be detected.
  • the updating module 56 is configured to re-determine the first width after the current display area is changed, and re-intercept and splicing the character string, and display the re-spliced character string.
  • the file name can be intercepted and spliced again.
  • the second file list line is all displayed, and the prefix portion of the third file name is compared with FIG. display more.
  • the interception string can be adaptively adapted according to the width of the current display area, thereby improving the flexibility of the string display.
  • the embodiment does not need to manually set information, and does not require human intervention, thereby reducing user overhead.
  • an embodiment of the present invention further provides an electronic device, including:
  • a memory for storing a user interaction interface, when the user interaction interface is executed by the processor, acquiring a first width, the first width is a width of a current display area, and acquiring a second width, where the second width is The string to be displayed displays a desired width in a single line; if the second width is greater than the first width, the character string is intercepted such that the display width of the truncated character string is less than or equal to the first width And splicing the intercepted character string; displaying the stitched string.
  • portions of the application can be implemented in hardware, software, firmware, or a combination thereof.
  • multiple steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system.
  • a suitable instruction execution system For example, if implemented in hardware, as in another embodiment, it can be implemented by any one or combination of the following techniques well known in the art: having logic gates for implementing logic functions on data signals. Discrete logic circuits, application specific integrated circuits with suitable combinational logic gates, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
  • each functional unit in each embodiment of the present application may be integrated into one processing module, or each unit may exist physically separately, or two or more units may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or in the form of software functional modules.
  • the integrated modules, if implemented in the form of software functional modules and sold or used as stand-alone products, may also be stored in a computer readable storage medium.
  • the above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

一种字符串的显示方法和装置,该字符串的显示方法包括:获取第一宽度,所述第一宽度是当前显示区域的宽度(S11);获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度(S12);如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接(S13);显示所述拼接后的字符串(S14)。该方法在显示字符串时不需要人为干预且可以提高灵活性。

Description

字符串的显示方法和装置 技术领域
本申请涉及数据处理技术领域,尤其涉及一种字符串的显示方法和装置。
背景技术
在电子设备的交互界面上,通常都需要向用户显示字符串,例如,在浏览器中显示文件名。通常来讲,电子设备的显示界面都有宽度限制,当要显示的字符串很长时,受限于电子设备的显示宽度,字符串在单行不能全部显示。
现有技术中,可以由用户预先设置单行显示的最大字符数,当字符串很长时,将超过最大字符数的字符直接去掉。但是,这种方式需要人为干预并且灵活性较差。
发明内容
本申请旨在至少在一定程度上解决相关技术中的技术问题之一。
为此,本申请的一个目的在于提出一种字符串的显示方法,该方法可以在显示字符串时不需要人为干预且可以提高灵活性。
本申请的另一个目的在于提出一种字符串的显示装置。
为达到上述目的,本申请第一方面实施例提出的字符串的显示方法,包括:获取第一宽度,所述第一宽度是当前显示区域的宽度;获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度;如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接;显示所述拼接后的字符串。
本申请第一方面实施例提出的字符串的显示方法,通过获取第一宽度和第二宽度,并根据第一宽度和第二宽度截取拼接字符串,可以实现根据当前显示区域的宽度自适应的截取字符串,从而提高字符串显示的灵活性,并且,本实施例也不需要人为预先设置信息,不需要人为干预,降低用户开销。
为达到上述目的,本申请第二方面实施例提出的字符串的显示装置,包括:第一获取模块,用于获取第一宽度,所述第一宽度是当前显示区域的宽度;第二获取模块,用于获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度;截取模块,用于如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接;显示模块,用于显示所述拼接后的字符串。
本申请第二方面实施例提出的字符串的显示装置,通过获取第一宽度和第二宽度,并根据第一宽度和第二宽度截取拼接字符串,可以实现根据当前显示区域的宽度自适应的截取字符串,从而提高字符串显示的灵活性,并且,本实施例也不需要人为预先设置信息,不需要人为干预,降低用户开销。
本申请附加的方面和优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本申请的实践了解到。
附图说明
本申请上述的和/或附加的方面和优点从下面结合附图对实施例的描述中将变得明显和容易理解,其中:
图1是本申请一实施例提出的字符串的显示方法的流程示意图;
图2是本申请另一实施例提出的字符串的显示方法的流程示意图;
图3是本申请实施例中文件名在一种显示区域中的显示示意图;
图4是本申请实施例中文件名在另一种显示区域中的显示示意图;
图5是本申请另一实施例提出的字符串的显示装置的结构示意图;
图6是本申请另一实施例提出的字符串的显示装置的结构示意图。
具体实施方式
下面详细描述本申请的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,仅用于解释本申请,而不能理解为对本申请的限制。相反,本申请的实施例包括落入所附加权利要求书的精神和内涵范围内的所有变化、修改和等同物。
图1是本申请一实施例提出的字符串的显示方法的流程示意图,该方法包括:
S11:获取第一宽度,所述第一宽度是当前显示区域的宽度。
其中,本实施例的方法可以由插件执行,例如,浏览器中加载的插件。
插件可以由javascript编写。
具体的,可以通过javascript的offsetwidth方法,获取当前显示区域的宽度。
S12:获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度。
具体的,可以通过document.defaultView.getComputedStyle方法,获取字符串当前所应用的级联样式表(Cascading Style Sheets,css)样式;再通过动态的创建一个空的文件对象模型(Document Object Model,dom)元素,在这个dom元素上,设定与字符串一样的css样式条件,主要是字体与字号,可以计算出字符串单行全部显示的宽度。
可选的,要显示的字符串可以是文件名。
可以理解的是,S11和S12无时序限制关系。
S13:如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接。
可选的,当第二宽度大于第一宽度时,可以截取字符串的后缀和前缀,之后再对前缀和后缀进行拼接。
可选的,所述截取所述字符串的后缀和前缀,包括:
根据预先配置的规则,截取所述字符串的后缀,并获取所述后缀的显示宽度;
根据所述第一宽度和所述后缀的显示宽度,确定前缀的显示宽度;
根据所述前缀的显示宽度,截取所述字符串的前缀。
可选的,字符串是文件名时,预先配置的规则包括:后缀包括文件名的文件类型部分,文件名的从终止字符开始从后到前选取的预设个数的字符,以及,省略号(…)。
例如,截取的后缀包括.jpg,文件名后部的N个字符,N可配置,N大于或等于0,以及,省略号(…)。
在确定出后缀后,可以获取后缀所需的显示宽度,用第一宽度减去后缀的显示宽度后,得到差值,将该差值确定为前缀的显示宽度。
从所述字符串的起始字符开始从前到后依次选取每个字符,直至从所述起始字符开始到当前选取的字符组成的字符串的显示宽度小于或等于所述前缀的显示宽度,且从所述起始字符开始到当前选取的字符的下一个字符组成的字符串的显示宽度大于所述前缀的显示宽度;将从所述起始字符开始到当前选取的字符组成的字符串确定为所述前缀。
例如,差值是A,则从文件名的第1个开始依次选择到第n个字符为例,其中,从第1个字符到第n个字符的显示宽度小于或等于A,从第1个字符到第n+1个字符的显示宽度大于A。
S14:显示所述拼接后的字符串。
例如,将截取的前缀和后缀直接组合得到拼接后的字符串。
以截取文件名为例,可以显示形如文件名_1…文件名_2.文件类型的字符串,其中,文件名_1和文件名_2分别包括文件名的前部和后部的字符。
本实施例的字符串可以包括中文,英文,数字中的一项或多项。
本实施例通过获取第一宽度和第二宽度,并根据第一宽度和第二宽度截取拼接字符串,可以实现根据当前显示区域的宽度自适应的截取字符串,从而提高字符串显示的灵活性,并且,本实施例也不需要人为预先设置信息,不需要人为干预,降低用户开销。
图2是本申请另一实施例提出的字符串的显示方法的流程示意图,本实施例以显示文 件名为例,该方法包括:
S21:获取第一宽度和第二宽度,所述第一宽度是当前显示区域的宽度,所述第二宽度是要显示的文件名单行显示所需的宽度。
例如,可以通过javascript的offsetwidth方法,获取当前显示区域的宽度。
可以通过document.defaultView.getComputedStyle方法,获取字符串当前所应用的级联样式表(Cascading Style Sheets,css)样式;再通过动态的创建一个空的文件对象模型(Document Object Model,dom)元素,在这个dom元素上,设定与字符串一样的css样式条件,主要是字体与字号,可以计算出字符串单行全部显示的宽度。
S22:判断所述第二宽度是否大于所述第一宽度,若是,执行S23,否则,执行S25。
S23:对所述文件名进行截取,并对截取后的文件名进行拼接。
可以截取文件名的后缀和前缀,之后再对前缀和后缀进行拼接。
具体的,可以预先设置后缀包括的内容,根据预先设置的信息先截取后缀,在截取后缀后根据剩余能够显示的宽度再截取前缀。具体的可以参见上述实施例,在此不再赘述。
S24:显示所述拼接后的文件名。
例如,参见图3,显示3个文件名,其中,第2个和第3个文件名的单行显示的全部宽度大于显示区域的宽度,此时,可以对第2个和第3个文件名进行截取和拼接,得到如图3所示的拼接后的文件名。
S25:直接显示所述文件名。
例如,参见图3,对第1个文件名直接显示。
可选的,如果当前显示区域改变,文件名也可以重新截取和拼接。参见图2,该方法还可以包括:
S26:检测到当前显示区域改变。
例如,可以根据重力感应事件,当感应到移动设备翻转后,可以检测到当前显示区域改变。重力感应事件例如为感应到移动设备向右或者向左翻转90度。
S27:在所述当前显示区域改变后,重新确定所述第一宽度,以及,重新对所述文件名进行截取和拼接,并显示重新拼接后的文件名。
例如,参见图4,当显示区域改变后,可以重新对文件名进行截取和拼接,例如,如图4所示,第2个文件名单行全部显示,第3个文件名的前缀部分相对于图2将显示更多。
本实施例通过根据当前显示区域的宽度截取文件名,可以实现显示的文件名自适应显示区域,不需要人工干预,可以提高灵活性;本实施例是根据显示区域的宽度和文件名的宽度进行截取,可以适用于字符串是英文和中文的情况;本实施例可以根据显示区域的改变而改变文件名的显示内容。
图5是本申请另一实施例提出的字符串的显示装置的结构示意图,该装置50包括第一获取模块51,第二获取模块52,截取模块53和显示模块54。
第一获取模块51用于获取第一宽度,所述第一宽度是当前显示区域的宽度;
具体的,可以通过javascript的offsetwidth方法,获取当前显示区域的宽度。
第二获取模块52用于获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度;
具体的,可以通过document.defaultView.getComputedStyle方法,获取字符串当前所应用的级联样式表(Cascading Style Sheets,css)样式;再通过动态的创建一个空的文件对象模型(Document Object Model,dom)元素,在这个dom元素上,设定与字符串一样的css样式条件,主要是字体与字号,可以计算出字符串单行全部显示的宽度。
可选的,要显示的字符串可以是文件名。
截取模块53用于如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接;
可选的,参见图6,所述截取模块53包括:
第一单元531,用于截取所述字符串的后缀和前缀;
第二单元532,用于拼接所述后缀和前缀,得到所述拼接后的字符串。
可选的,所述第一单元531具体用于:
根据预先配置的规则,截取所述字符串的后缀,并获取所述后缀的显示宽度;
根据所述第一宽度和所述后缀的显示宽度,确定前缀的显示宽度;
根据所述前缀的显示宽度,截取所述字符串的前缀。
可选的,所述前缀的显示宽度是所述第一宽度与所述后缀的显示宽度的差值,所述第一单元531具体用于:
从所述字符串的起始字符开始从前到后依次选取每个字符,直至从所述起始字符开始到当前选取的字符组成的字符串的显示宽度小于或等于所述前缀的显示宽度,且从所述起始字符开始到当前选取的字符的下一个字符组成的字符串的显示宽度大于所述前缀的显示宽度;
将从所述起始字符开始到当前选取的字符组成的字符串确定为所述前缀。
例如,截取的后缀包括.jpg,文件名后部的N个字符,N可配置,N大于或等于0,以及,省略号(…)。
在确定出后缀后,可以获取后缀所需的显示宽度,用第一宽度减去后缀的显示宽度后,得到差值,将该差值确定为前缀的显示宽度。
例如,差值是A,则从文件名的第1个开始依次选择到第n个字符为例,其中,从第1 个字符到第n个字符的显示宽度小于或等于A,从第1个字符到第n+1个字符的显示宽度大于A。
显示模块54用于显示所述拼接后的字符串。
例如,将截取的前缀和后缀直接组合得到拼接后的字符串。
以截取文件名为例,可以显示形如文件名_1…文件名_2.文件类型的字符串,其中,文件名_1和文件名_2分别包括文件名的前部和后部的字符。
本实施例的字符串可以包括中文,英文,数字中的一项或多项。
另一实施例中,参见图6,该装置50还包括:
检测模块55,用于检测到当前显示区域改变;
例如,可以根据重力感应事件,当感应到移动设备翻转后,可以检测到当前显示区域改变。
更新模块56,用于在所述当前显示区域改变后,重新确定所述第一宽度,以及,重新对所述字符串进行截取和拼接,并显示重新拼接后的字符串。
例如,初始显示时,参见图3,,显示3个文件名,其中,第2个和第3个文件名的单行显示的全部宽度大于显示区域的宽度,此时,可以对第2个和第3个文件名进行截取和拼接,得到如图3所示的拼接后的文件名。
当显示区域改变后,参见图4,可以重新对文件名进行截取和拼接,例如,如图4所示,第2个文件名单行全部显示,第3个文件名的前缀部分相对于图2将显示更多。
本实施例通过获取第一宽度和第二宽度,并根据第一宽度和第二宽度截取拼接字符串,可以实现根据当前显示区域的宽度自适应的截取字符串,从而提高字符串显示的灵活性,并且,本实施例也不需要人为预先设置信息,不需要人为干预,降低用户开销。
另外,本发明实施例还提出了一种电子设备,包括:
显示屏;
处理器;
存储器,用于存储用户交互界面,所述用户交互界面被所述处理器执行时,获取第一宽度,所述第一宽度是当前显示区域的宽度;获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度;如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接;显示所述拼接后的字符串。
需要说明的是,在本申请的描述中,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性。此外,在本申请的描述中,除非另有说明,“多个”的含义是两个或两个以上。
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本申请的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本申请的实施例所属技术领域的技术人员所理解。
应当理解,本申请的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。例如,如果用硬件来实现,和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。
本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。
此外,在本申请各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。
上述提到的存储介质可以是只读存储器,磁盘或光盘等。
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本申请的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任何的一个或多个实施例或示例中以合适的方式结合。
尽管上面已经示出和描述了本申请的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本申请的限制,本领域的普通技术人员在本申请的范围内可以对上述实施例进行变化、修改、替换和变型。

Claims (13)

  1. 一种字符串的显示方法,其特征在于,包括:
    获取第一宽度,所述第一宽度是当前显示区域的宽度;
    获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度;
    如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接;
    显示所述拼接后的字符串。
  2. 根据权利要求1所述的方法,其特征在于,所述对所述字符串进行截取,包括:截取所述字符串的后缀和前缀;
    所述对截取后的字符串进行拼接,包括:拼接所述后缀和前缀,得到所述拼接后的字符串。
  3. 根据权利要求2所述的方法,其特征在于,所述截取所述字符串的后缀和前缀,包括:
    根据预先配置的规则,截取所述字符串的后缀,并获取所述后缀的显示宽度;
    根据所述第一宽度和所述后缀的显示宽度,确定前缀的显示宽度;
    根据所述前缀的显示宽度,截取所述字符串的前缀。
  4. 根据权利要求3所述的方法,其特征在于,所述字符串是文件名,所述后缀包括如下项中的至少一项:
    所述文件名中的文件类型部分;
    所述文件名的从终止字符开始从后到前选取的预设个数的字符;
    省略号。
  5. 根据权利要求3所述的方法,其特征在于,所述前缀的显示宽度是所述第一宽度与所述后缀的显示宽度的差值,所述根据所述前缀的显示宽度,截取所述字符串的前缀,包括:
    从所述字符串的起始字符开始从前到后依次选取每个字符,直至从所述起始字符开始到当前选取的字符组成的字符串的显示宽度小于或等于所述前缀的显示宽度,且从所述起始字符开始到当前选取的字符的下一个字符组成的字符串的显示宽度大于所述前缀的显示宽度;
    将从所述起始字符开始到当前选取的字符组成的字符串确定为所述前缀。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述显示所述截取后的字符串之后,所述方法还包括:
    检测到当前显示区域改变;
    在所述当前显示区域改变后,重新确定所述第一宽度,以及,重新对所述字符串进行截取和拼接,并显示重新拼接后的字符串。
  7. 根据权利要求1-5任一项所述的方法,其特征在于,所述获取第二宽度之后,所述方法还包括:
    如果所述第二宽度小于或等于所述第一宽度,直接显示所述字符串。
  8. 一种字符串的显示装置,其特征在于,包括:
    第一获取模块,用于获取第一宽度,所述第一宽度是当前显示区域的宽度;
    第二获取模块,用于获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度;
    截取模块,用于如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接;
    显示模块,用于显示所述拼接后的字符串。
  9. 根据权利要求8所述的装置,其特征在于,所述截取模块包括:
    第一单元,用于截取所述字符串的后缀和前缀;
    第二单元,用于拼接所述后缀和前缀,得到所述拼接后的字符串。
  10. 根据权利要求9所述的装置,其特征在于,所述第一单元具体用于:
    根据预先配置的规则,截取所述字符串的后缀,并获取所述后缀的显示宽度;
    根据所述第一宽度和所述后缀的显示宽度,确定前缀的显示宽度;
    根据所述前缀的显示宽度,截取所述字符串的前缀。
  11. 根据权利要求9所述的装置,其特征在于,所述前缀的显示宽度是所述第一宽度与所述后缀的显示宽度的差值,所述第一单元具体用于:
    从所述字符串的起始字符开始从前到后依次选取每个字符,直至从所述起始字符开始到当前选取的字符组成的字符串的显示宽度小于或等于所述前缀的显示宽度,且从所述起始字符开始到当前选取的字符的下一个字符组成的字符串的显示宽度大于所述前缀的显示宽度;
    将从所述起始字符开始到当前选取的字符组成的字符串确定为所述前缀。
  12. 根据权利要求8-11任一项所述的装置,其特征在于,还包括:
    检测模块,用于检测到当前显示区域改变;
    更新模块,用于在所述当前显示区域改变后,重新确定所述第一宽度,以及,重新对所述字符串进行截取和拼接,并显示重新拼接后的字符串。
  13. 一种电子设备,其特征在于,包括:
    显示屏;
    处理器;
    存储器,用于存储用户交互界面,所述用户交互界面被所述处理器执行时,获取第一宽度,所述第一宽度是当前显示区域的宽度;获取第二宽度,所述第二宽度是要显示的字符串单行显示所需的宽度;如果所述第二宽度大于所述第一宽度,对所述字符串进行截取,使得截取后的字符串的显示宽度小于或等于所述第一宽度,并对截取后的字符串进行拼接;显示所述拼接后的字符串。
PCT/CN2015/097655 2014-12-26 2015-12-17 字符串的显示方法和装置 Ceased WO2016101833A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410834610.1 2014-12-26
CN201410834610.1A CN105786308A (zh) 2014-12-26 2014-12-26 字符串的显示方法和装置

Publications (1)

Publication Number Publication Date
WO2016101833A1 true WO2016101833A1 (zh) 2016-06-30

Family

ID=56149253

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/097655 Ceased WO2016101833A1 (zh) 2014-12-26 2015-12-17 字符串的显示方法和装置

Country Status (2)

Country Link
CN (1) CN105786308A (zh)
WO (1) WO2016101833A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3522007A4 (en) * 2016-10-12 2019-11-13 Huawei Technologies Co., Ltd. CHARACTER CHARACTERIZATION METHOD AND TERMINAL DEVICE
CN110633437A (zh) * 2018-05-31 2019-12-31 阿里巴巴集团控股有限公司 一种多行省略显示的方法及装置
CN111062186A (zh) * 2019-12-06 2020-04-24 金蝶软件(中国)有限公司 文本处理方法、装置、计算机设备和存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110114748A (zh) 2017-10-09 2019-08-09 华为技术有限公司 一种显示处理方法及电子设备
CN109002505A (zh) * 2018-06-29 2018-12-14 郑州云海信息技术有限公司 一种目标字符串的显示方法及相关装置
CN112596803A (zh) * 2020-08-24 2021-04-02 文思海辉智科科技有限公司 控件字串截断检查方法、装置、计算机设备和存储介质
CN112861045A (zh) * 2021-02-20 2021-05-28 北京金山云网络技术有限公司 文案的显示方法和装置、存储介质、电子装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080126432A1 (en) * 2006-11-24 2008-05-29 Samsung Electronics Co., Ltd. Method and apparatus for shortening file name
CN102111505A (zh) * 2011-03-04 2011-06-29 中山大学 一种移动终端短信息提示显示方法
CN102239490A (zh) * 2008-12-09 2011-11-09 高通股份有限公司 用于调整文本串的长度以配合显示器大小的方法和设备
CN103324638A (zh) * 2012-03-22 2013-09-25 腾讯科技(深圳)有限公司 文件名显示方法及系统
US20140139530A1 (en) * 2012-11-21 2014-05-22 Appsense Limited Systems and methods for user viewable truncation
CN104281644A (zh) * 2014-08-22 2015-01-14 广州三星通信技术研究有限公司 文件名信息的显示方法和装置

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102708774B (zh) * 2012-04-19 2015-04-08 广东威创视讯科技股份有限公司 字符串显示方法和系统
CN104063362B (zh) * 2013-07-18 2016-03-16 腾讯科技(深圳)有限公司 一种字符串截断方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080126432A1 (en) * 2006-11-24 2008-05-29 Samsung Electronics Co., Ltd. Method and apparatus for shortening file name
CN102239490A (zh) * 2008-12-09 2011-11-09 高通股份有限公司 用于调整文本串的长度以配合显示器大小的方法和设备
CN102111505A (zh) * 2011-03-04 2011-06-29 中山大学 一种移动终端短信息提示显示方法
CN103324638A (zh) * 2012-03-22 2013-09-25 腾讯科技(深圳)有限公司 文件名显示方法及系统
US20140139530A1 (en) * 2012-11-21 2014-05-22 Appsense Limited Systems and methods for user viewable truncation
CN104281644A (zh) * 2014-08-22 2015-01-14 广州三星通信技术研究有限公司 文件名信息的显示方法和装置

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3522007A4 (en) * 2016-10-12 2019-11-13 Huawei Technologies Co., Ltd. CHARACTER CHARACTERIZATION METHOD AND TERMINAL DEVICE
US10942621B2 (en) 2016-10-12 2021-03-09 Huawei Technologies Co., Ltd. Character string display method and terminal device
CN110633437A (zh) * 2018-05-31 2019-12-31 阿里巴巴集团控股有限公司 一种多行省略显示的方法及装置
CN111062186A (zh) * 2019-12-06 2020-04-24 金蝶软件(中国)有限公司 文本处理方法、装置、计算机设备和存储介质

Also Published As

Publication number Publication date
CN105786308A (zh) 2016-07-20

Similar Documents

Publication Publication Date Title
WO2016101833A1 (zh) 字符串的显示方法和装置
ES2657670T3 (es) Sistema y procedimiento de navegación por el contenido de un artículo
US20160188550A1 (en) Dynamic simulation of a responsive web page
US8881055B1 (en) HTML pop-up control
US20130283145A1 (en) Approximating Electronic Document Last Reading Position
US9378297B2 (en) Task-based address bar and tabs scaling
BR112016003431B1 (pt) Método implantado por computador, sistema e meio legível por máquina não transitório para comutar guias em um aplicativo
US20120092269A1 (en) Computer-implemented method for manipulating onscreen data
US20120072444A1 (en) Detection and display of volatile data
JP2015520900A5 (zh)
US10878175B2 (en) Portlet display on portable computing devices
US9858698B2 (en) Text resizing within an embedded image
JP2015029307A5 (zh)
CN104268152B (zh) 一种网页展现方法和装置
WO2018010530A1 (zh) 一种对多个多媒体文件的存储、读取和显示方法及装置
US20200142571A1 (en) Optimizing Window Resize Actions for Remoted Applications
CN105786920B (zh) 界面标签的展现方法和装置
WO2015139487A1 (zh) 搜索推荐方法和装置
BR112021004393A2 (pt) interface de seleção com elementos de sugestão sincronizados
US20140006936A1 (en) Responsive document breakpoints systems and methods
US20140143653A1 (en) Method and system for providing web page using dynamic page partitioning
US12561513B2 (en) Reading typesetting method, apparatus, device and storage medium
US10372806B2 (en) Data display technique for aggregate display of related data
GB2533366A (en) Methods of controlling document display devices and document display devices
WO2017012296A1 (zh) 触摸显示驱动方法及装置、显示装置和应用处理器

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: 15871901

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15871901

Country of ref document: EP

Kind code of ref document: A1