fix: correctly propagate eol mode to status bar widgets
This commit is contained in:
		
							parent
							
								
									fb0531de5c
								
							
						
					
					
						commit
						9080fd4826
					
				
					 3 changed files with 17 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -190,6 +190,7 @@ pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message
 | 
			
		|||
        self.file_dirty = false;
 | 
			
		||||
        self.name = root.abbreviate_home(&self.name_buf, self.name);
 | 
			
		||||
    } else if (try m.match(.{ "E", "open", tp.extract(&file_path), tp.extract(&self.file_exists), tp.extract(&file_type), tp.extract(&file_icon), tp.extract(&self.file_color) })) {
 | 
			
		||||
        self.eol_mode = .lf;
 | 
			
		||||
        @memcpy(self.name_buf[0..file_path.len], file_path);
 | 
			
		||||
        self.name = self.name_buf[0..file_path.len];
 | 
			
		||||
        @memcpy(self.file_type_buf[0..file_type.len], file_type);
 | 
			
		||||
| 
						 | 
				
			
			@ -207,6 +208,7 @@ pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message
 | 
			
		|||
        self.column = 0;
 | 
			
		||||
        self.file_exists = true;
 | 
			
		||||
        self.file = false;
 | 
			
		||||
        self.eol_mode = .lf;
 | 
			
		||||
        self.show_project();
 | 
			
		||||
    } else if (try m.match(.{ "PRJ", "open" })) {
 | 
			
		||||
        if (!self.file)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,8 +34,9 @@ fn on_click(_: *Self, _: *Button.State(Self)) void {
 | 
			
		|||
    command.executeName("goto", .{}) catch {};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn layout(self: *Self, _: *Button.State(Self)) Widget.Layout {
 | 
			
		||||
    return .{ .static = self.rendered.len };
 | 
			
		||||
pub fn layout(self: *Self, btn: *Button.State(Self)) Widget.Layout {
 | 
			
		||||
    const len = btn.plane.egc_chunk_width(self.rendered, 0);
 | 
			
		||||
    return .{ .static = len };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme) bool {
 | 
			
		||||
| 
						 | 
				
			
			@ -64,11 +65,15 @@ pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message
 | 
			
		|||
        self.format();
 | 
			
		||||
    } else if (try m.match(.{ "E", "eol_mode", tp.extract(&eol_mode) })) {
 | 
			
		||||
        self.eol_mode = @enumFromInt(eol_mode);
 | 
			
		||||
        self.format();
 | 
			
		||||
    } else if (try m.match(.{ "E", "open", tp.more })) {
 | 
			
		||||
        self.eol_mode = .lf;
 | 
			
		||||
    } else if (try m.match(.{ "E", "close" })) {
 | 
			
		||||
        self.lines = 0;
 | 
			
		||||
        self.line = 0;
 | 
			
		||||
        self.column = 0;
 | 
			
		||||
        self.rendered = "";
 | 
			
		||||
        self.eol_mode = .lf;
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue