ui

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(file *os.File) bool

IsTerminal 判断输出环境,是否是输出到终端界面,如果重定向到文件则不用进行下载统计打印输出了

Types

type DownloadDashboard

type DownloadDashboard struct {
	// contains filtered or unexported fields
}

DownloadDashboard 下载任务统计面板使用了很多ANSI转义序列。并不是所有的终端都支持ANSI转义序列,所以需要做兼容性处理。

func NewDownloadDashboard

func NewDownloadDashboard(parallel int, globalSpeeds *speeds.Speeds, opts *DownloadDashboardOptions) *DownloadDashboard

NewDownloadDashboard 创建下载任务统计面板

func (*DownloadDashboard) Close

func (db *DownloadDashboard) Close()

Close 关闭面板

func (*DownloadDashboard) Logf

func (db *DownloadDashboard) Logf(format string, a ...interface{})

Logf 增加日志

func (*DownloadDashboard) MarkTaskState

func (db *DownloadDashboard) MarkTaskState(id string, state TaskState, message string)

MarkTaskState 标记任务状态

func (*DownloadDashboard) RegisterTask

func (db *DownloadDashboard) RegisterTask(id, path string, total int64, isFile bool)

RegisterTask 注册任务信息

func (*DownloadDashboard) Start

func (db *DownloadDashboard) Start()

Start 启动面板

func (*DownloadDashboard) UpdateTaskInfo

func (db *DownloadDashboard) UpdateTaskInfo(id, name string, total int64, isFile bool)

UpdateTaskInfo 更新任务信息

func (*DownloadDashboard) UpdateTaskProgress

func (db *DownloadDashboard) UpdateTaskProgress(id string, downloaded, total, speed int64, eta time.Duration)

UpdateTaskProgress 更新任务进度

type DownloadDashboardOptions

type DownloadDashboardOptions struct {
	Title       string
	MaxHistory  int
	ActiveSlots int
	Output      io.Writer
}

type TaskState

type TaskState int
const (
	TaskQueued TaskState = iota
	TaskRunning
	TaskSuccess
	TaskFailed
	TaskSkipped
	TaskCanceled
)

Jump to

Keyboard shortcuts

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