textutil

package
v0.17.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package textutil provides shared text writing utilities for naga codegen backends.

All three text backends (GLSL, HLSL, MSL) need indent-aware text writing. This package extracts the common IndentWriter to eliminate duplication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndentWriter

type IndentWriter struct {
	// Out is the output buffer.
	Out strings.Builder

	// Indent is the current indentation level (each level = 4 spaces).
	Indent int
}

IndentWriter writes indented text to a strings.Builder. Embed this in backend Writer structs to get indent-aware output methods.

func (*IndentWriter) PopIndent

func (w *IndentWriter) PopIndent()

PopIndent decreases indentation by one level. Does not go below zero.

func (*IndentWriter) PushIndent

func (w *IndentWriter) PushIndent()

PushIndent increases indentation by one level.

func (*IndentWriter) WriteIndent

func (w *IndentWriter) WriteIndent()

WriteIndent writes the current indentation (4 spaces per level).

func (*IndentWriter) WriteLine

func (w *IndentWriter) WriteLine(format string, args ...any)

WriteLine writes indented text followed by a newline. If args are provided, format is treated as a fmt.Fprintf format string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL