CopySelectToMime copies selected rows to mime data
()
| 663 | |
| 664 | // CopySelectToMime copies selected rows to mime data |
| 665 | func (tb *Table) CopySelectToMime() mimedata.Mimes { |
| 666 | nitms := len(tb.SelectedIndexes) |
| 667 | if nitms == 0 { |
| 668 | return nil |
| 669 | } |
| 670 | ix := &table.IndexView{} |
| 671 | ix.Table = tb.Table.Table |
| 672 | idx := tb.SelectedIndexesList(false) // ascending |
| 673 | iidx := make([]int, len(idx)) |
| 674 | for i, di := range idx { |
| 675 | iidx[i] = tb.Table.Indexes[di] |
| 676 | } |
| 677 | ix.Indexes = iidx |
| 678 | var b bytes.Buffer |
| 679 | ix.WriteCSV(&b, table.Tab, table.Headers) |
| 680 | md := mimedata.NewTextBytes(b.Bytes()) |
| 681 | md[0].Type = fileinfo.DataCsv |
| 682 | return md |
| 683 | } |
| 684 | |
| 685 | // FromMimeData returns records from csv of mime data |
| 686 | func (tb *Table) FromMimeData(md mimedata.Mimes) [][]string { |
nothing calls this directly
no test coverage detected