mirror of https://github.com/anoshenko/rui.git
				
				
				
			Added "tab-size" property
This commit is contained in:
		
							parent
							
								
									06ccffa900
								
							
						
					
					
						commit
						3d52de161b
					
				|  | @ -2,10 +2,10 @@ | |||
| 
 | ||||
| * Requires go 1.18 or higher | ||||
| * The "interface{}" type replaced by "any" | ||||
| * Added "accent-color", "overflow", "arrow", "arrow-align", "arrow-size", "arrow-width", and "arrow-offset" properties  | ||||
| * Added "accent-color", "tab-size", "overflow", "arrow", "arrow-align", "arrow-size", "arrow-width", and "arrow-offset" properties  | ||||
| * Added "@ruiArrowSize" and "@ruiArrowWidth" constants to the default theme | ||||
| * Added Transition, Transitions, and SetTransition functions to the ViewStyle interface | ||||
| * Added GetAccentColor, GetOverflow, IsTimingFunctionValid, and GetTransitions functions | ||||
| * Added GetAccentColor, GetTabSize, GetOverflow, IsTimingFunctionValid, and GetTransitions functions | ||||
| * Changed GetTransition functions | ||||
| * Added the OpenURL function to the Session interface | ||||
| 
 | ||||
|  |  | |||
|  | @ -1408,6 +1408,11 @@ radius необходимо передать nil | |||
| | WhiteSpacePreLine     | Сохраняются как в источнике | Объединяются в один пробел  | Переносится       | Удаляются                   | | ||||
| | WhiteSpaceBreakSpaces | Сохраняются как в источнике | Сохраняются как в источнике | Переносится       | Переносятся                 | | ||||
| 
 | ||||
| #### Свойство "tab-size" | ||||
| 
 | ||||
| Свойство "tab-size" (константа TabSize) типа int задает размер символа табуляции (U+0009) в пробелах. | ||||
| Значение свойства "tab-size" должно быть больше 0. | ||||
| 
 | ||||
| #### Свойство "word-break" | ||||
| 
 | ||||
| Свойство "word-break" (константа WordBreak) типа int определяет, где будет установлен перевод | ||||
|  |  | |||
							
								
								
									
										13
									
								
								README.md
								
								
								
								
							
							
						
						
									
										13
									
								
								README.md
								
								
								
								
							|  | @ -1391,20 +1391,25 @@ The table below shows the behavior of various values of the "white-space" proper | |||
| | WhiteSpacePreLine     | Preserve  | Collapse        | Wrap          | Remove             | Hang                               | | ||||
| | WhiteSpaceBreakSpaces | Preserve  | Preserve        | Wrap          | Wrap               | Wrap                               | | ||||
| 
 | ||||
| #### "tab-size" property | ||||
| 
 | ||||
| The "tab-size" int property (TabSize constant) specifies the size of the tab character (U+0009) in spaces. | ||||
| The value of the "tab-size" property must be greater than 0. The default value is 8 | ||||
| 
 | ||||
| #### "word-break" property | ||||
| 
 | ||||
| The "word-break" int property (WordBreak constant) determines where the newline will be set if the text exceeds the block boundaries. | ||||
| The "white-space" property can take the following values: | ||||
| 
 | ||||
| 0 (constant WordBreak, name "normal) - default behavior for linefeed placement. | ||||
| 0 (WordBreak constant, "normal" name) - default behavior for linefeed placement. | ||||
| 
 | ||||
| 1 (constant WordBreakAll, name "break-all) - if the block boundaries are exceeded,  | ||||
| 1 (WordBreakAll constant, "break-all" name) - if the block boundaries are exceeded,  | ||||
| a line break will be inserted between any two characters (except for Chinese/Japanese/Korean text). | ||||
| 
 | ||||
| 2 (constant WordBreakKeepAll, name "keep-all) - Line break will not be used in Chinese/Japanese/ Korean text.  | ||||
| 2 (WordBreakKeepAll constant, "keep-all" name) - Line break will not be used in Chinese/Japanese/ Korean text.  | ||||
| For text in other languages, the default behavior (normal) will be applied. | ||||
| 
 | ||||
| 3 (constant WordBreakWord, name "break-word) - when the block boundaries are exceeded,  | ||||
| 3 (WordBreakWord constant, "break-word" name) - when the block boundaries are exceeded,  | ||||
| the remaining whole words can be broken in an arbitrary place, if a more suitable place for line break is not found. | ||||
| 
 | ||||
| #### "strikethrough", "overline", "underline" properties | ||||
|  |  | |||
|  | @ -42,6 +42,16 @@ func valueToSizeUnit(value any, session Session) (SizeUnit, bool) { | |||
| 			if text, ok := session.resolveConstants(value); ok { | ||||
| 				return StringToSizeUnit(text) | ||||
| 			} | ||||
| 
 | ||||
| 		case float64: | ||||
| 			return Px(value), true | ||||
| 
 | ||||
| 		case float32: | ||||
| 			return Px(float64(value)), true | ||||
| 		} | ||||
| 
 | ||||
| 		if n, ok := isInt(value); ok { | ||||
| 			return Px(float64(n)), true | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -359,6 +359,11 @@ const ( | |||
| 	// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.
 | ||||
| 	TextShadow = "text-shadow" | ||||
| 
 | ||||
| 	// TabSize is the constant for the "tab-size" property tag.
 | ||||
| 	// The "tab-size" int property sets the width of tab characters (U+0009) in spaces.
 | ||||
| 	// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.
 | ||||
| 	TabSize = "tab-size" | ||||
| 
 | ||||
| 	// LetterSpacing is the constant for the "letter-spacing" property tag.
 | ||||
| 	// The "letter-spacing" SizeUnit property sets the horizontal spacing behavior between text characters.
 | ||||
| 	// This value is added to the natural spacing between characters while rendering the text.
 | ||||
|  |  | |||
|  | @ -67,6 +67,7 @@ var boolProperties = []string{ | |||
| 
 | ||||
| var intProperties = []string{ | ||||
| 	ZIndex, | ||||
| 	TabSize, | ||||
| 	HeadHeight, | ||||
| 	FootHeight, | ||||
| 	RowSpan, | ||||
|  |  | |||
							
								
								
									
										6
									
								
								view.go
								
								
								
								
							
							
						
						
									
										6
									
								
								view.go
								
								
								
								
							|  | @ -591,9 +591,9 @@ func viewPropertyChanged(view *viewData, tag string) { | |||
| 		} | ||||
| 		return | ||||
| 
 | ||||
| 	case ZIndex: | ||||
| 		if i, ok := intProperty(view, ZIndex, session, 0); ok { | ||||
| 			updateCSSProperty(htmlID, ZIndex, strconv.Itoa(i), session) | ||||
| 	case ZIndex, TabSize: | ||||
| 		if i, ok := intProperty(view, tag, session, 0); ok { | ||||
| 			updateCSSProperty(htmlID, tag, strconv.Itoa(i), session) | ||||
| 		} | ||||
| 		return | ||||
| 
 | ||||
|  |  | |||
|  | @ -279,6 +279,10 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) { | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if tabSize, ok := intProperty(style, TabSize, session, 8); ok && tabSize > 0 { | ||||
| 		builder.add(TabSize, strconv.Itoa(tabSize)) | ||||
| 	} | ||||
| 
 | ||||
| 	if text := style.cssTextDecoration(session); text != "" { | ||||
| 		builder.add("text-decoration", text) | ||||
| 	} | ||||
|  |  | |||
|  | @ -156,7 +156,7 @@ func GetOverflow(view View, subviewID string) int { | |||
| // GetZIndex returns the subview z-order.
 | ||||
| // If the second argument (subviewID) is "" then a z-order of the first argument (view) is returned
 | ||||
| func GetZIndex(view View, subviewID string) int { | ||||
| 	return intStyledProperty(view, subviewID, Visibility, 0) | ||||
| 	return intStyledProperty(view, subviewID, ZIndex, 0) | ||||
| } | ||||
| 
 | ||||
| // GetWidth returns the subview width.
 | ||||
|  | @ -366,6 +366,12 @@ func GetTextSize(view View, subviewID string) SizeUnit { | |||
| 	return sizeStyledProperty(view, subviewID, TextSize, true) | ||||
| } | ||||
| 
 | ||||
| // GetTabSize returns the subview width of tab characters (U+0009) in spaces.
 | ||||
| // If the second argument (subviewID) is "" then a width of the first argument (view) is returned
 | ||||
| func GetTabSize(view View, subviewID string) int { | ||||
| 	return intStyledProperty(view, subviewID, TabSize, 8) | ||||
| } | ||||
| 
 | ||||
| // GetTextWeight returns a text weight of the subview. Returns one of next values:
 | ||||
| // 1, 2, 3, 4 (normal text), 5, 6, 7 (bold text), 8 and 9
 | ||||
| // If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue